RFR: 8327963: C2: fix construction of memory graph around Initialize node to prevent incorrect execution if allocation is removed [v5]

Roland Westrelin roland at openjdk.org
Thu May 15 12:39:54 UTC 2025


On Mon, 28 Apr 2025 13:20:45 GMT, Roberto Castañeda Lozano <rcastanedalo at openjdk.org> wrote:

> Thanks for working on this, Roland! A "dumb" question: could the issue also be addressed by ensuring that dead allocations are removed earlier (e.g. in the call to `PhaseMacroExpand::eliminate_allocate_node` performed as part of escape analysis/scalar replacement, before loop optimizations)? It seems this would also prevent the miscompilations in `TestEliminationOfAllocationWithoutUse`, no?

I don't thing that would work (but haven't tried). The problem is that the memory graph is broken around `Initialize` nodes from the time they are added to the IR (parse time) and that's only exposed once they are removed from the graph. But I don't think it matters when they are removed.

What you suggest does also sound quite conservative: it could very well be that an allocation looses all its uses after some rounds of optimization but in the scheme you suggest, that allocation wouldn't be optimized out.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/24570#issuecomment-2883668589


More information about the hotspot-compiler-dev mailing list