8312617: SIGSEGV in ConnectionGraph::verify_ram_nodes

Reviewed-by: kvn, thartmann
This commit is contained in:
Cesar Soares Lucas 2023-08-02 14:27:07 +00:00 committed by Tobias Hartmann
parent b093880acd
commit 6446792327
3 changed files with 31 additions and 9 deletions

@ -109,7 +109,7 @@ void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci, boo
bool subsume_loads = SubsumeLoads;
bool do_escape_analysis = DoEscapeAnalysis;
bool do_iterative_escape_analysis = DoEscapeAnalysis;
bool do_reduce_allocation_merges = ReduceAllocationMerges;
bool do_reduce_allocation_merges = ReduceAllocationMerges && EliminateAllocations;
bool eliminate_boxing = EliminateAutoBox;
bool do_locks_coarsening = EliminateLocks;

@ -2321,8 +2321,9 @@ void Compile::Optimize() {
TracePhase tp("macroEliminate", &timers[_t_macroEliminate]);
PhaseMacroExpand mexp(igvn);
mexp.eliminate_macro_nodes();
igvn.set_delay_transform(false);
if (failing()) return;
igvn.set_delay_transform(false);
igvn.optimize();
print_method(PHASE_ITER_GVN_AFTER_ELIMINATION, 2);
}

@ -48,7 +48,7 @@ ConnectionGraph::ConnectionGraph(Compile * C, PhaseIterGVN *igvn, int invocation
// pushed to the ConnectionGraph. The code below bumps the initial capacity of
// _nodes by 10% to account for these additional nodes. If capacity is exceeded
// the array will be reallocated.
_nodes(C->comp_arena(), ReduceAllocationMerges ? C->unique()*1.10 : C->unique(), C->unique(), nullptr),
_nodes(C->comp_arena(), C->do_reduce_allocation_merges() ? C->unique()*1.10 : C->unique(), C->unique(), nullptr),
_in_worklist(C->comp_arena()),
_next_pidx(0),
_collecting(true),
@ -398,7 +398,7 @@ bool ConnectionGraph::compute_escape() {
}
// 6. Remove reducible allocation merges from ideal graph
if (ReduceAllocationMerges && reducible_merges.size() > 0) {
if (reducible_merges.size() > 0) {
bool delay = _igvn->delay_transform();
_igvn->set_delay_transform(true);
for (uint i = 0; i < reducible_merges.size(); i++ ) {
@ -502,8 +502,9 @@ bool ConnectionGraph::can_reduce_phi_check_users(PhiNode* ophi) const {
// details.
bool ConnectionGraph::can_reduce_phi(PhiNode* ophi) const {
// If there was an error attempting to reduce allocation merges for this
// method we might have disabled the compilation and be retrying
// with RAM disabled.
// method we might have disabled the compilation and be retrying with RAM
// disabled.
// If EliminateAllocations is False, there is no point in reducing merges.
if (!_compile->do_reduce_allocation_merges()) {
return false;
}
@ -720,7 +721,12 @@ void ConnectionGraph::reduce_phi(PhiNode* ophi) {
if (use->is_SafePoint()) {
safepoints.push(use->as_SafePoint());
} else {
assert(false, "Unexpected use of reducible Phi.");
#ifdef ASSERT
ophi->dump(-3);
assert(false, "Unexpected user of reducible Phi %d -> %d:%s", ophi->_idx, use->_idx, use->Name());
#endif
_compile->record_failure(C2Compiler::retry_no_reduce_allocation_merges());
return;
}
}
@ -730,8 +736,9 @@ void ConnectionGraph::reduce_phi(PhiNode* ophi) {
}
void ConnectionGraph::verify_ram_nodes(Compile* C, Node* root) {
Unique_Node_List ideal_nodes;
if (!C->do_reduce_allocation_merges()) return;
Unique_Node_List ideal_nodes;
ideal_nodes.map(C->live_nodes(), nullptr); // preallocate space
ideal_nodes.push(root);
@ -2296,7 +2303,7 @@ void ConnectionGraph::adjust_scalar_replaceable_state(JavaObjectNode* jobj, Uniq
continue;
}
if (ReduceAllocationMerges && use_n->is_Phi() && can_reduce_phi(use_n->as_Phi())) {
if (use_n->is_Phi() && can_reduce_phi(use_n->as_Phi())) {
candidates.push(use_n);
} else {
// Mark all objects as NSR if we can't remove the merge
@ -3885,6 +3892,20 @@ void ConnectionGraph::split_unique_types(GrowableArray<Node *> &alloc_worklist,
}
#ifdef ASSERT
// At this point reducible Phis shouldn't have AddP users anymore; only SafePoints.
for (uint i = 0; i < reducible_merges.size(); i++) {
Node* phi = reducible_merges.at(i);
for (DUIterator_Fast jmax, j = phi->fast_outs(jmax); j < jmax; j++) {
Node* use = phi->fast_out(j);
if (!use->is_SafePoint()) {
phi->dump(-3);
assert(false, "Unexpected user of reducible Phi -> %s", use->Name());
}
}
}
#endif
// Go over all ArrayCopy nodes and if one of the inputs has a unique
// type, record it in the ArrayCopy node so we know what memory this
// node uses/modified.