[PATCH] D12481: x86: Don't mark live-in callee-saved registers as killed

John Kåre Alsaker via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 30 10:27:24 PDT 2015


Zoxc created this revision.
Zoxc added a subscriber: llvm-commits.
Zoxc set the repository for this revision to rL LLVM.

This makes it possible to use callee-saved registers as arguments to a function. I have a custom calling convention on x64 which does this (it's the System V ABI with RBX added in first place to the allowed registers).

Should such an calling convention be added to LLVM so that we can test for callee-saved register being live-in?



Repository:
  rL LLVM

http://reviews.llvm.org/D12481

Files:
  lib/Target/X86/X86FrameLowering.cpp

Index: lib/Target/X86/X86FrameLowering.cpp
===================================================================
--- lib/Target/X86/X86FrameLowering.cpp
+++ lib/Target/X86/X86FrameLowering.cpp
@@ -1338,10 +1338,16 @@
 
     if (!X86::GR64RegClass.contains(Reg) && !X86::GR32RegClass.contains(Reg))
       continue;
-    // Add the callee-saved register as live-in. It's killed at the spill.
-    MBB.addLiveIn(Reg);
 
-    BuildMI(MBB, MI, DL, TII.get(Opc)).addReg(Reg, RegState::Kill)
+    auto IsLive = MBB.isLiveIn(Reg);
+
+    if (!IsLive) {
+      // Add the callee-saved register as live-in. It's killed at the spill.
+      MBB.addLiveIn(Reg);
+    }
+
+    // Kill the register if it wasn't live previously.
+    BuildMI(MBB, MI, DL, TII.get(Opc)).addReg(Reg, IsLive ? 0 : RegState::Kill)
       .setMIFlag(MachineInstr::FrameSetup);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12481.33540.patch
Type: text/x-patch
Size: 847 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150830/7e1c2ac8/attachment.bin>


More information about the llvm-commits mailing list