Skip to content

Commit 180489e

Browse files
committed
[GR-65958] Partial escape analysis: materialize for too many fixpoint iterations.
PullRequest: graal/21125
2 parents a8c6b61 + 123dc4c commit 180489e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/virtual/phases/ea/EffectsClosure.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ protected BlockT merge(HIRBlock merge, List<BlockT> states) {
355355
@Override
356356
@SuppressWarnings("try")
357357
protected final List<BlockT> processLoop(CFGLoop<HIRBlock> loop, BlockT initialState) {
358+
final StructuredGraph graph = loop.getHeader().getBeginNode().graph();
358359
if (initialState.isDead()) {
359360
ArrayList<BlockT> states = new ArrayList<>();
360361
for (int i = 0; i < loop.getLoopExits().size(); i++) {
@@ -425,6 +426,8 @@ protected final List<BlockT> processLoop(CFGLoop<HIRBlock> loop, BlockT initialS
425426
loopLocationKillCacheCopy.putAll(loopLocationKillCache);
426427
}
427428
}
429+
430+
boolean tooManyIterationsSeen = false;
428431
while (true) { // // TERMINATION ARGUMENT: bound by number of basic blocks and iterative
429432
// loop traversal
430433
CompilationAlarm.checkProgress(cfg.graph);
@@ -538,7 +541,18 @@ protected final List<BlockT> processLoop(CFGLoop<HIRBlock> loop, BlockT initialS
538541
currentMode = EffectsClosureMode.MATERIALIZE_ALL;
539542
continue;
540543
}
541-
throw new GraalError("too many iterations at %s", loop);
544+
if (!tooManyIterationsSeen) {
545+
tooManyIterationsSeen = true;
546+
/*
547+
* The first time we see that we did too many iterations we materialize everything
548+
* before the loop and see if that fixes our problems.
549+
*/
550+
graph.getDebug().dump(DebugContext.VERY_DETAILED_LEVEL, graph, "Too many loop iterations for %s trying to materialize everything before loop and redo loop nest", loop);
551+
currentMode = EffectsClosureMode.MATERIALIZE_ALL;
552+
continue;
553+
} else {
554+
throw new GraalError("too many iterations at %s", loop);
555+
}
542556
}
543557
}
544558

0 commit comments

Comments
 (0)