During folding for patchpoint/stackmap instructions, defer creation of new MIs
authorLang Hames <lhames@gmail.com>
Fri, 15 Nov 2013 23:13:21 +0000 (23:13 +0000)
committerLang Hames <lhames@gmail.com>
Fri, 15 Nov 2013 23:13:21 +0000 (23:13 +0000)
until we know that folding will be successful.

No functional change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194880 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86InstrInfo.cpp

index 304d92261465e285b1dc01faf776fb2b10dd6733..1a6d5ca829dd6dbdb65e02608adb1aba39db094b 100644 (file)
@@ -4207,10 +4207,6 @@ static MachineInstr* foldPatchpoint(MachineFunction &MF,
                 !MI->getOperand(0).isImplicit();
   unsigned StartIdx = hasDef ? 1 : 0;
 
-  MachineInstr *NewMI =
-    MF.CreateMachineInstr(TII.get(MI->getOpcode()), MI->getDebugLoc(), true);
-  MachineInstrBuilder MIB(MF, NewMI);
-
   switch (MI->getOpcode()) {
   case TargetOpcode::STACKMAP:
     StartIdx += 2; // Skip ID, nShadowBytes.
@@ -4231,6 +4227,11 @@ static MachineInstr* foldPatchpoint(MachineFunction &MF,
     if (*I < StartIdx)
       return 0;
   }
+
+  MachineInstr *NewMI =
+    MF.CreateMachineInstr(TII.get(MI->getOpcode()), MI->getDebugLoc(), true);
+  MachineInstrBuilder MIB(MF, NewMI);
+
   // No need to fold return, the meta data, and function arguments
   for (unsigned i = 0; i < StartIdx; ++i)
     MIB.addOperand(MI->getOperand(i));