HDeoptimize should hold values live in env.

Values that are not live in compiled code anymore may still be needed in
interpreter, due to code motion, etc.

Bug: 22665511
Change-Id: I8b85833c5c462f8fe36f86d6026a51b07563995a
diff --git a/compiler/optimizing/ssa_liveness_analysis.h b/compiler/optimizing/ssa_liveness_analysis.h
index 220ee6a..a7044de 100644
--- a/compiler/optimizing/ssa_liveness_analysis.h
+++ b/compiler/optimizing/ssa_liveness_analysis.h
@@ -1201,8 +1201,14 @@
   // Update the live_out set of the block and returns whether it has changed.
   bool UpdateLiveOut(const HBasicBlock& block);
 
-  static bool ShouldBeLiveForEnvironment(HInstruction* instruction) {
+  // Returns whether `instruction` in an HEnvironment held by `env_holder`
+  // should be kept live by the HEnvironment.
+  static bool ShouldBeLiveForEnvironment(HInstruction* env_holder,
+                                         HInstruction* instruction) {
     if (instruction == nullptr) return false;
+    // A value that's not live in compiled code may still be needed in interpreter,
+    // due to code motion, etc.
+    if (env_holder->IsDeoptimize()) return true;
     if (instruction->GetBlock()->GetGraph()->IsDebuggable()) return true;
     return instruction->GetType() == Primitive::kPrimNot;
   }