[jdk16] RFR: 8255763: C2: OSR miscompilation caused by invalid memory instruction placement

Christian Hagedorn chagedorn at openjdk.java.net
Fri Dec 18 10:13:57 UTC 2020


On Tue, 15 Dec 2020 11:05:36 GMT, Roberto Castañeda Lozano <rcastanedalo at openjdk.org> wrote:

> Disable GCM hoisting of memory-writing nodes for irreducible CFGs. This prevents GCM from wrongly "hoisting" stores into descendants of their original loop. Such an "inverted hoisting" can happen due to `CFGLoop::compute_freq()`'s inaccurate estimation of frequencies for irreducible CFGs.
> 
> Extend CFG verification code by checking that memory-writing nodes are placed in either their original loop or an ancestor.
> 
> Add tests for the reducible and irreducible cases. The former was already handled correctly before the change (the frequency estimation model prevents "inverted hoisting" for reducible CFGs), and is just added for coverage.
> 
> This change addresses the specific miscompilation issue in a conservative way, for simplicity and safety. Future work includes investigating if only the illegal blocks can be discarded as candidates for GCM hoisting, and refining frequency estimation for irreducible CFGs.

Nice summary in the JBS issue! That looks good to me and I agree with Vladimir to do this fix in 16 and proceed with an RFE to further investigate the mentioned improvement possibilities.

src/hotspot/share/opto/block.cpp line 1229:

> 1227:       // CFGs, and by special handling in PhaseCFG::schedule_late() otherwise.
> 1228:       if (n->is_Mach() && n->bottom_type()->has_memory() && n->in(0) != NULL) {
> 1229:         Block *original_block = find_block_for_node(n->in(0));

`*` should be at `Block`.

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

Marked as reviewed by chagedorn (Reviewer).

PR: https://git.openjdk.java.net/jdk16/pull/22


More information about the hotspot-compiler-dev mailing list