Skip to content

Commit

Permalink
[JIT] Backport 8255120: C2: assert(outer->outcnt() >= phis + 2 && out…
Browse files Browse the repository at this point in the history
…er->outcnt() <= phis + 2 + stores + 1) failed: only phis
  • Loading branch information
kuaiwei committed Jan 9, 2025
1 parent 04af2db commit bb0b823
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
5 changes: 5 additions & 0 deletions src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ bool ShenandoahBarrierC2Support::expand(Compile* C, PhaseIterGVN& igvn) {
ShenandoahBarrierSetC2State* state = ShenandoahBarrierSetC2::bsc2()->state();
if ((state->iu_barriers_count() +
state->load_reference_barriers_count()) > 0) {
assert(C->post_loop_opts_phase(), "no loop opts allowed");
C->reset_post_loop_opts_phase(); // ... but we know what we are doing
bool attempt_more_loopopts = ShenandoahLoopOptsAfterExpansion;
C->clear_major_progress();
PhaseIdealLoop ideal_loop(igvn, LoopOptsShenandoahExpand);
Expand All @@ -58,7 +60,10 @@ bool ShenandoahBarrierC2Support::expand(Compile* C, PhaseIterGVN& igvn) {
return false;
}
C->clear_major_progress();

C->process_for_post_loop_opts_igvn(igvn);
}
C->set_post_loop_opts_phase(); // now for real!
}
return true;
}
Expand Down
38 changes: 16 additions & 22 deletions src/hotspot/share/opto/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1989,16 +1989,21 @@ void Compile::remove_from_post_loop_opts_igvn(Node* n) {
}

void Compile::process_for_post_loop_opts_igvn(PhaseIterGVN& igvn) {
if (_for_post_loop_igvn.length() == 0) {
return; // no work to do
}
while (_for_post_loop_igvn.length() > 0) {
Node* n = _for_post_loop_igvn.pop();
n->remove_flag(Node::Flag_for_post_loop_opts_igvn);
igvn._worklist.push(n);
// Verify that all previous optimizations produced a valid graph
// at least to this point, even if no loop optimizations were done.
PhaseIdealLoop::verify(igvn);

C->set_post_loop_opts_phase(); // no more loop opts allowed

if (_for_post_loop_igvn.length() > 0) {
while (_for_post_loop_igvn.length() > 0) {
Node* n = _for_post_loop_igvn.pop();
n->remove_flag(Node::Flag_for_post_loop_opts_igvn);
igvn._worklist.push(n);
}
igvn.optimize();
assert(_for_post_loop_igvn.length() == 0, "no more delayed nodes allowed");
}
igvn.optimize();
assert(_for_post_loop_igvn.length() == 0, "no more delayed nodes allowed");
}

// StringOpts and late inlining of string methods
Expand Down Expand Up @@ -2369,7 +2374,6 @@ void Compile::Optimize() {
}
if (!failing()) {
// Verify that last round of loop opts produced a valid graph
TracePhase tp("idealLoopVerify", &timers[_t_idealLoopVerify]);
PhaseIdealLoop::verify(igvn);
}
}
Expand Down Expand Up @@ -2405,15 +2409,9 @@ void Compile::Optimize() {

if (failing()) return;

// Ensure that major progress is now clear
C->clear_major_progress();
C->clear_major_progress(); // ensure that major progress is now clear

{
// Verify that all previous optimizations produced a valid graph
// at least to this point, even if no loop optimizations were done.
TracePhase tp("idealLoopVerify", &timers[_t_idealLoopVerify]);
PhaseIdealLoop::verify(igvn);
}
process_for_post_loop_opts_igvn(igvn);

#ifdef ASSERT
BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
Expand All @@ -2440,10 +2438,6 @@ void Compile::Optimize() {
}
#endif

C->set_post_loop_opts_phase(); // no more loop opts allowed

process_for_post_loop_opts_igvn(igvn);

if (C->max_vector_size() > 0) {
C->optimize_logic_cones(igvn);
igvn.optimize();
Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/share/opto/compile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,9 @@ class Compile : public Phase {
void remove_coarsened_lock(Node* n);
bool coarsened_locks_consistent();

bool post_loop_opts_phase() { return _post_loop_opts_phase; }
void set_post_loop_opts_phase() { _post_loop_opts_phase = true; }
bool post_loop_opts_phase() { return _post_loop_opts_phase; }
void set_post_loop_opts_phase() { _post_loop_opts_phase = true; }
void reset_post_loop_opts_phase() { _post_loop_opts_phase = false; }

void record_for_post_loop_opts_igvn(Node* n);
void remove_from_post_loop_opts_igvn(Node* n);
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/opto/loopnode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,8 @@ class PhaseIdealLoop : public PhaseTransform {
// is useful to verify that all inputs properly dominate their uses.
static void verify(PhaseIterGVN& igvn) {
#ifdef ASSERT
ResourceMark rm;
Compile::TracePhase tp("idealLoopVerify", &timers[_t_idealLoopVerify]);
PhaseIdealLoop v(igvn);
#endif
}
Expand Down

0 comments on commit bb0b823

Please sign in to comment.