8261730: C2 compilation fails with assert(store->find_edge(load) != -1) failed: missing precedence edge

Relax assertion in PhaseCFG::verify() to accept the case where a store is used
to implement an implicit null check and a load is placed in the null block.

Reviewed-by: thartmann, kvn
This commit is contained in:
Roberto Castañeda Lozano 2021-03-04 07:48:51 +00:00
parent 7915a1fc4c
commit 4cfecceb04
4 changed files with 82 additions and 2 deletions

View file

@ -770,7 +770,24 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) {
// Add an anti-dep edge, and squeeze 'load' into the highest block.
assert(store != load->find_exact_control(load->in(0)), "dependence cycle found");
if (verify) {
assert(store->find_edge(load) != -1, "missing precedence edge");
#ifdef ASSERT
// We expect an anti-dependence edge from 'load' to 'store', except when
// implicit_null_check() has hoisted 'store' above its early block to
// perform an implicit null check, and 'load' is placed in the null
// block. In this case it is safe to ignore the anti-dependence, as the
// null block is only reached if 'store' tries to write to null.
Block* store_null_block = NULL;
Node* store_null_check = store->find_out_with(Op_MachNullCheck);
if (store_null_check != NULL) {
Node* if_true = store_null_check->find_out_with(Op_IfTrue);
assert(if_true != NULL, "null check without null projection");
Node* null_block_region = if_true->find_out_with(Op_Region);
assert(null_block_region != NULL, "null check without null region");
store_null_block = get_block_for_node(null_block_region);
}
#endif
assert(LCA == store_null_block || store->find_edge(load) != -1,
"missing precedence edge");
} else {
store->add_prec(load);
}