Explicitly set the scale to 1 on some segstack prologue instrs.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 11 Jan 2012 18:14:03 +0000 (18:14 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 11 Jan 2012 18:14:03 +0000 (18:14 +0000)
Patch by Brian Anderson.

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

lib/Target/X86/X86FrameLowering.cpp
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/segmented-stacks.ll

index ac3ec89964e3978e3c1e12cfcfa9e5b905c8c7ec..058b39a1c7148740f7269947708a9184411ed7a1 100644 (file)
@@ -1385,10 +1385,10 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
       ScratchReg = X86::RSP;
     else
       BuildMI(checkMBB, DL, TII.get(X86::LEA64r), ScratchReg).addReg(X86::RSP)
-        .addImm(0).addReg(0).addImm(-StackSize).addReg(0);
+        .addImm(1).addReg(0).addImm(-StackSize).addReg(0);
 
     BuildMI(checkMBB, DL, TII.get(X86::CMP64rm)).addReg(ScratchReg)
-      .addReg(0).addImm(0).addReg(0).addImm(TlsOffset).addReg(TlsReg);
+      .addReg(0).addImm(1).addReg(0).addImm(TlsOffset).addReg(TlsReg);
   } else {
     TlsReg = X86::GS;
     TlsOffset = 0x30;
@@ -1397,7 +1397,7 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
       ScratchReg = X86::ESP;
     else
       BuildMI(checkMBB, DL, TII.get(X86::LEA32r), ScratchReg).addReg(X86::ESP)
-        .addImm(0).addReg(0).addImm(-StackSize).addReg(0);
+        .addImm(1).addReg(0).addImm(-StackSize).addReg(0);
 
     BuildMI(checkMBB, DL, TII.get(X86::CMP32rm)).addReg(ScratchReg)
       .addReg(0).addImm(0).addReg(0).addImm(TlsOffset).addReg(TlsReg);
index 4409389e7c45fe586788a8f1c0603ef7c45b154c..771ca082506dd3f01d1840659f29703ab252bd94 100644 (file)
@@ -12066,7 +12066,7 @@ X86TargetLowering::EmitLoweredSegAlloca(MachineInstr *MI, MachineBasicBlock *BB,
   BuildMI(BB, DL, TII->get(Is64Bit ? X86::SUB64rr:X86::SUB32rr), SPLimitVReg)
     .addReg(tmpSPVReg).addReg(sizeVReg);
   BuildMI(BB, DL, TII->get(Is64Bit ? X86::CMP64mr:X86::CMP32mr))
-    .addReg(0).addImm(0).addReg(0).addImm(TlsOffset).addReg(TlsReg)
+    .addReg(0).addImm(1).addReg(0).addImm(TlsOffset).addReg(TlsReg)
     .addReg(SPLimitVReg);
   BuildMI(BB, DL, TII->get(X86::JG_4)).addMBB(mallocMBB);
 
index 4f529c119f050f2be9921b2d658fcdc2c4ae8a6a..7854cbd060a676543b0d4f3f34cfcc4f1013073c 100644 (file)
@@ -1,6 +1,10 @@
 ; RUN: llc < %s -mtriple=i686-linux -segmented-stacks -verify-machineinstrs | FileCheck %s -check-prefix=X32
 ; RUN: llc < %s -mtriple=x86_64-linux  -segmented-stacks -verify-machineinstrs | FileCheck %s -check-prefix=X64
 
+; We used to crash with filetype=obj
+; RUN: llc < %s -mtriple=i686-linux -segmented-stacks -filetype=obj
+; RUN: llc < %s -mtriple=x86_64-linux -segmented-stacks -filetype=obj
+
 ; Just to prevent the alloca from being optimized away
 declare void @dummy_use(i32*, i32)