Skip to content

Commit

Permalink
8291775: C2: assert(r != __null && r->is_Region()) failed: this phi m…
Browse files Browse the repository at this point in the history
…ust have a region

Backport-of: 32d675ca607d341ca3428efc32e212701775e3c6
  • Loading branch information
GoeLin committed Oct 5, 2022
1 parent ed3b13a commit 19ccadf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/hotspot/share/opto/stringopts.cpp
Expand Up @@ -294,10 +294,12 @@ void StringConcat::eliminate_unneeded_control() {
Node* cmp = bol->in(1);
assert(cmp->is_Cmp(), "unexpected if shape");
if (cmp->in(1)->is_top() || cmp->in(2)->is_top()) {
// This region should lose its Phis and be optimized out by igvn but there's a chance the if folds to top first
// which then causes a reachable part of the graph to become dead.
// This region should lose its Phis. They are removed either in PhaseRemoveUseless (for data phis) or in IGVN
// (for memory phis). During IGVN, there is a chance that the If folds to top before the Region is processed
// which then causes a reachable part of the graph to become dead. To prevent this, set the boolean input of
// the If to a constant to nicely let the diamond Region/If fold away.
Compile* C = _stringopts->C;
C->gvn_replace_by(n, iff->in(0));
C->gvn_replace_by(iff->in(1), _stringopts->gvn()->intcon(0));
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/hotspot/jtreg/compiler/c2/Test7179138_1.java
Expand Up @@ -30,6 +30,9 @@
* compiler.c2.Test7179138_1
* @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN compiler.c2.Test7179138_1
* @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation
* -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN -XX:+AlwaysIncrementalInline
* compiler.c2.Test7179138_1
*
* @author Skip Balk
*/
Expand Down

1 comment on commit 19ccadf

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.