Set the deopt flag after adjusting the stack pointer.

One should not write to something below the stack pointer, or
it could be overwritten during an interrupt.

Test: test.py
Change-Id: Ie6c997b9f7548ca5844303d6a3fc0c531f469c6e
diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc
index 7331a9e..57319ce 100644
--- a/compiler/optimizing/code_generator_x86_64.cc
+++ b/compiler/optimizing/code_generator_x86_64.cc
@@ -1298,12 +1298,6 @@
     }
   }
 
-  if (GetGraph()->HasShouldDeoptimizeFlag()) {
-    // Initialize should_deoptimize flag to 0.
-    __ movl(Address(CpuRegister(RSP), xmm_spill_location - kShouldDeoptimizeFlagSize),
-            Immediate(0));
-  }
-
   // Save the current method if we need it. Note that we do not
   // do this in HCurrentMethod, as the instruction might have been removed
   // in the SSA graph.
@@ -1311,6 +1305,11 @@
     __ movq(Address(CpuRegister(RSP), kCurrentMethodStackOffset),
             CpuRegister(kMethodRegisterArgument));
   }
+
+  if (GetGraph()->HasShouldDeoptimizeFlag()) {
+    // Initialize should_deoptimize flag to 0.
+    __ movl(Address(CpuRegister(RSP), GetStackOffsetOfShouldDeoptimizeFlag()), Immediate(0));
+  }
 }
 
 void CodeGeneratorX86_64::GenerateFrameExit() {