summaryrefslogtreecommitdiff
path: root/compiler/optimizing
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/optimizing')
-rw-r--r--compiler/optimizing/builder.cc20
-rw-r--r--compiler/optimizing/builder.h3
-rw-r--r--compiler/optimizing/nodes.h1
-rw-r--r--compiler/optimizing/optimizing_compiler.cc5
-rw-r--r--compiler/optimizing/optimizing_compiler_stats.h1
5 files changed, 23 insertions, 7 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index b28c2d9592..fbec52d88f 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -113,8 +113,10 @@ static bool NeedsExtraGotoBlock(HBasicBlock* block) {
return !last_instruction->IsThrow();
}
-void HGraphBuilder::MaybeAddExtraGotoBlocks() {
- if (graph_->GetExitBlock() == nullptr) return;
+bool HGraphBuilder::MaybeAddExtraGotoBlocks() {
+ if (graph_->GetExitBlock() == nullptr) {
+ return true;
+ }
bool added_block = false;
for (size_t pred = 0, size = graph_->GetExitBlock()->GetPredecessors().size(); pred < size;
@@ -130,13 +132,17 @@ void HGraphBuilder::MaybeAddExtraGotoBlocks() {
// TODO(solanes): Avoid recomputing the full dominator tree by manually updating the relevant
// information (loop information, dominance, try catch information).
if (added_block) {
- DCHECK(!graph_->HasIrreducibleLoops())
- << "Recomputing loop information in graphs with irreducible loops "
- << "is unsupported, as it could lead to loop header changes";
+ if (graph_->HasIrreducibleLoops()) {
+ // Recomputing loop information in graphs with irreducible loops is unsupported, as it could
+ // lead to loop header changes. In this case it is safe to abort since we don't inline graphs
+ // with irreducible loops anyway.
+ return false;
+ }
graph_->ClearLoopInformation();
graph_->ClearDominanceInformation();
graph_->BuildDominatorTree();
}
+ return true;
}
GraphAnalysisResult HGraphBuilder::BuildGraph(bool build_for_inline) {
@@ -193,7 +199,9 @@ GraphAnalysisResult HGraphBuilder::BuildGraph(bool build_for_inline) {
// 5) When inlining, we want to add a Goto block if we have Return/ReturnVoid->TryBoundary->Exit
// since we will have Return/ReturnVoid->TryBoundary->`continue to normal execution` once inlined.
if (build_for_inline) {
- MaybeAddExtraGotoBlocks();
+ if (!MaybeAddExtraGotoBlocks()) {
+ return kAnalysisFailInliningIrreducibleLoop;
+ }
}
// 6) Type the graph and eliminate dead/redundant phis.
diff --git a/compiler/optimizing/builder.h b/compiler/optimizing/builder.h
index a59e78285f..2964ad5c9b 100644
--- a/compiler/optimizing/builder.h
+++ b/compiler/optimizing/builder.h
@@ -56,7 +56,8 @@ class HGraphBuilder : public ValueObject {
// When inlining, we sometimes want to add an extra Goto block before the Exit block. This is done
// in the building phase as we do not allow the inlining phase to add new instructions.
- void MaybeAddExtraGotoBlocks();
+ // Returns false if the graph we are adding the extra block has irreducible loops.
+ bool MaybeAddExtraGotoBlocks();
HGraph* const graph_;
const DexFile* const dex_file_;
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index 44e342f018..278d232b23 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -137,6 +137,7 @@ enum GraphAnalysisResult {
kAnalysisInvalidBytecode,
kAnalysisFailThrowCatchLoop,
kAnalysisFailAmbiguousArrayOp,
+ kAnalysisFailInliningIrreducibleLoop,
kAnalysisFailIrreducibleLoopAndStringInit,
kAnalysisFailPhiEquivalentInOsr,
kAnalysisSuccess,
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index b4bf477dff..76e35963db 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -869,6 +869,11 @@ CodeGenerator* OptimizingCompiler::TryCompile(ArenaAllocator* allocator,
MethodCompilationStat::kNotCompiledAmbiguousArrayOp);
break;
}
+ case kAnalysisFailInliningIrreducibleLoop: {
+ MaybeRecordStat(compilation_stats_.get(),
+ MethodCompilationStat::kNotCompiledInliningIrreducibleLoop);
+ break;
+ }
case kAnalysisFailIrreducibleLoopAndStringInit: {
MaybeRecordStat(compilation_stats_.get(),
MethodCompilationStat::kNotCompiledIrreducibleLoopAndStringInit);
diff --git a/compiler/optimizing/optimizing_compiler_stats.h b/compiler/optimizing/optimizing_compiler_stats.h
index 313f3ef9d8..24a28e3393 100644
--- a/compiler/optimizing/optimizing_compiler_stats.h
+++ b/compiler/optimizing/optimizing_compiler_stats.h
@@ -59,6 +59,7 @@ enum class MethodCompilationStat {
kNotCompiledSpaceFilter,
kNotCompiledUnhandledInstruction,
kNotCompiledUnsupportedIsa,
+ kNotCompiledInliningIrreducibleLoop,
kNotCompiledIrreducibleLoopAndStringInit,
kNotCompiledPhiEquivalentInOsr,
kInlinedMonomorphicCall,