summaryrefslogtreecommitdiff
path: root/compiler/optimizing
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2016-04-18 15:37:01 +0100
committer Vladimir Marko <vmarko@google.com> 2016-04-19 13:59:15 +0100
commitfd66c50d64c38e40bafde83b4872e27bbff7546d (patch)
treee77ea1374211042d5eca3d1a62a81293a29eb108 /compiler/optimizing
parentc4d445a40bf00ab497b5e4d43a6b43eaafb5fa50 (diff)
Fix inlining loops in OSR mode.
When compiling a method in OSR mode and the method does not contain a loop (arguably, a very odd case) but we inline another method with a loop and then the final DCE re-runs the loop identification, the inlined loop would previously be marked as irreducible. However, the SSA liveness analysis expects irreducible loop to have extra loop Phis which were already eliminated from the loop before the inner graph was inlined to the outer graph, so we would fail a DCHECK(). We fix this by not marking inlined loops as irreducible when compiling in OSR mode. Bug: 28210356 Change-Id: If10057ed883333c62a878ed2ae3fe01bb5280e33
Diffstat (limited to 'compiler/optimizing')
-rw-r--r--compiler/optimizing/nodes.cc19
-rw-r--r--compiler/optimizing/ssa_liveness_analysis.cc2
2 files changed, 19 insertions, 2 deletions
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index 1afa36a89c..5091c7b626 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -618,7 +618,24 @@ void HLoopInformation::Populate() {
}
}
- if (is_irreducible_loop || graph->IsCompilingOsr()) {
+ if (!is_irreducible_loop && graph->IsCompilingOsr()) {
+ // When compiling in OSR mode, all loops in the compiled method may be entered
+ // from the interpreter. We treat this OSR entry point just like an extra entry
+ // to an irreducible loop, so we need to mark the method's loops as irreducible.
+ // This does not apply to inlined loops which do not act as OSR entry points.
+ if (suspend_check_ == nullptr) {
+ // Just building the graph in OSR mode, this loop is not inlined. We never build an
+ // inner graph in OSR mode as we can do OSR transition only from the outer method.
+ is_irreducible_loop = true;
+ } else {
+ // Look at the suspend check's environment to determine if the loop was inlined.
+ DCHECK(suspend_check_->HasEnvironment());
+ if (!suspend_check_->GetEnvironment()->IsFromInlinedInvoke()) {
+ is_irreducible_loop = true;
+ }
+ }
+ }
+ if (is_irreducible_loop) {
irreducible_ = true;
graph->SetHasIrreducibleLoops(true);
}
diff --git a/compiler/optimizing/ssa_liveness_analysis.cc b/compiler/optimizing/ssa_liveness_analysis.cc
index 83e9dacb1a..134c1f65e4 100644
--- a/compiler/optimizing/ssa_liveness_analysis.cc
+++ b/compiler/optimizing/ssa_liveness_analysis.cc
@@ -318,7 +318,7 @@ void SsaLivenessAnalysis::ComputeLiveRanges() {
for (uint32_t idx : live_in->Indexes()) {
HInstruction* instruction = GetInstructionFromSsaIndex(idx);
DCHECK(instruction->GetBlock()->IsEntryBlock()) << instruction->DebugName();
- DCHECK(!instruction->IsParameterValue()) << instruction->DebugName();
+ DCHECK(!instruction->IsParameterValue());
DCHECK(instruction->IsCurrentMethod() || instruction->IsConstant())
<< instruction->DebugName();
}