RFR: 8339303: C2: dead node after failing to match cloned address expression
Roberto Castañeda Lozano
rcastanedalo at openjdk.org
Mon Nov 4 09:44:52 UTC 2024
This changeset prevents the x86 platform-specific logic from cloning address expressions consisting of two chained `AddP` nodes with a small constant offset each, such as in the following example:

Such patterns cannot be fully subsumed into x86 complex addressing modes, and cloning them can cause the matcher to introduce dead nodes that trigger a segmentation fault in the subsequent global code motion phase. See a detailed analysis of the failure in the [JBS issue description](https://bugs.openjdk.org/browse/JDK-8339303).
The changeset additionally extends the post-matching verification logic to check that no old node is reachable by travesing both node inputs and outputs. This extension would have caused the original test case to fail directly after matching with an informative assertion message rather than an opaque segmentation fault in an unrelated code generation phase.
Note that the pattern causing the failure should be in general optimized by `AddPNode::Ideal` into a single `AddP` node with the constant sum of the offsets. While [JDK-8343067](https://bugs.openjdk.org/browse/JDK-8343067) should address the missing optimization, this changeset proposes a complementary solution that is easily backportable and avoids relying on specific optimizations for correctness.
#### Testing
##### Functionality
- tier1-5 (linux-x64, windows-x64, macosx-x64, linux-aarch64, macosx-aarch64; release and debug mode).
##### Performance
- Tested performance on a set of standard benchmark suites (DaCapo, SPECjbb2015, SPECjvm2008). No significant change was observed.
-------------
Commit messages:
- Remove fix condition
- Add regression test
- Verify that there are no out references to dead nodes after matching
- Do not clone two pointer adds using each an immediate on x86
Changes: https://git.openjdk.org/jdk/pull/21829/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21829&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8339303
Stats: 73 lines in 3 files changed: 67 ins; 3 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/21829.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/21829/head:pull/21829
PR: https://git.openjdk.org/jdk/pull/21829
More information about the hotspot-compiler-dev
mailing list