[PATCH] D39636: [X86] Don't clobber reserved registers with stack adjustments

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 7 00:51:13 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL317551: [X86] Don't clobber reserved registers with stack adjustments (authored by bsteinbr).

Repository:
  rL LLVM

https://reviews.llvm.org/D39636

Files:
  llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
  llvm/trunk/test/CodeGen/X86/pop-stack-cleanup-msvc.ll


Index: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
+++ llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
@@ -2577,6 +2577,7 @@
   unsigned Regs[2];
   unsigned FoundRegs = 0;
 
+  auto &MRI = MBB.getParent()->getRegInfo();
   auto RegMask = Prev->getOperand(1);
 
   auto &RegClass =
@@ -2590,6 +2591,10 @@
     if (!RegMask.clobbersPhysReg(Candidate))
       continue;
 
+    // Don't clobber reserved registers
+    if (MRI.isReserved(Candidate))
+      continue;
+
     bool IsDef = false;
     for (const MachineOperand &MO : Prev->implicit_operands()) {
       if (MO.isReg() && MO.isDef() &&
Index: llvm/trunk/test/CodeGen/X86/pop-stack-cleanup-msvc.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/pop-stack-cleanup-msvc.ll
+++ llvm/trunk/test/CodeGen/X86/pop-stack-cleanup-msvc.ll
@@ -0,0 +1,26 @@
+; RUN: llc < %s | FileCheck %s
+
+target triple = "i686--windows-msvc"
+
+declare { i8*, i32 } @param2_ret2(i32, i32)
+declare i32 @__CxxFrameHandler3(...)
+
+
+define void @test_reserved_regs() minsize optsize personality i32 (...)* @__CxxFrameHandler3 {
+; CHECK-LABEL: test_reserved_regs:
+; CHECK: calll _param2_ret2
+; CHECK-NEXT: popl %ecx
+; CHECK-NEXT: popl %edi
+start:
+  %s = alloca i64
+  store i64 4, i64* %s
+  %0 = invoke { i8*, i32 } @param2_ret2(i32 0, i32 1)
+          to label %out unwind label %cleanup
+
+out:
+  ret void
+
+cleanup:
+  %cp = cleanuppad within none []
+  cleanupret from %cp unwind to caller
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39636.121844.patch
Type: text/x-patch
Size: 1614 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171107/cb987b15/attachment.bin>


More information about the llvm-commits mailing list