Fix a crash due to a combination of dce/inlining.
Dead code elimiation was removing HCurrentMethod if
it ended up not being used, but inlining requires access
to it. Therefore we should keep the node in the graph.
Change-Id: I2f44f71b4ff3f2c3f9569d8420c1b37f00e694d2
diff --git a/compiler/optimizing/dead_code_elimination.cc b/compiler/optimizing/dead_code_elimination.cc
index b31de98..17a006c 100644
--- a/compiler/optimizing/dead_code_elimination.cc
+++ b/compiler/optimizing/dead_code_elimination.cc
@@ -122,7 +122,12 @@
if (!inst->HasSideEffects()
&& !inst->CanThrow()
&& !inst->IsSuspendCheck()
- && !inst->IsMemoryBarrier() // If we added an explicit barrier then we should keep it.
+ // The current method needs to stay in the graph in case of inlining.
+ // It is always passed anyway, and keeping it in the graph does not
+ // affect the generated code.
+ && !inst->IsCurrentMethod()
+ // If we added an explicit barrier then we should keep it.
+ && !inst->IsMemoryBarrier()
&& !inst->HasUses()) {
block->RemoveInstruction(inst);
MaybeRecordStat(MethodCompilationStat::kRemovedDeadInstruction);