[llvm] r314165 - X86: remove R12 from CSR on Windows x64 SwiftCC
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 25 15:00:17 PDT 2017
Author: compnerd
Date: Mon Sep 25 15:00:17 2017
New Revision: 314165
URL: http://llvm.org/viewvc/llvm-project?rev=314165&view=rev
Log:
X86: remove R12 from CSR on Windows x64 SwiftCC
R12 is used for the SwiftError parameter. It is no longer a CSR as it
is used for transfer the SwiftError, and the caller must preserve it if
they need to.
Modified:
llvm/trunk/lib/Target/X86/X86CallingConv.td
llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
llvm/trunk/test/CodeGen/X86/swift-error.ll
Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CallingConv.td?rev=314165&r1=314164&r2=314165&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86CallingConv.td (original)
+++ llvm/trunk/lib/Target/X86/X86CallingConv.td Mon Sep 25 15:00:17 2017
@@ -1050,6 +1050,8 @@ def CSR_Win64_NoSSE : CalleeSavedRegs<(a
def CSR_Win64 : CalleeSavedRegs<(add CSR_Win64_NoSSE,
(sequence "XMM%u", 6, 15))>;
+def CSR_Win64_SwiftError : CalleeSavedRegs<(sub CSR_Win64, R12)>;
+
// The function used by Darwin to obtain the address of a thread-local variable
// uses rdi to pass a single parameter and rax for the return value. All other
// GPRs are preserved.
Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=314165&r1=314164&r2=314165&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Mon Sep 25 15:00:17 2017
@@ -271,12 +271,13 @@ X86RegisterInfo::getCalleeSavedRegs(cons
assert(MF && "MachineFunction required");
const X86Subtarget &Subtarget = MF->getSubtarget<X86Subtarget>();
+ const Function *F = MF->getFunction();
bool HasSSE = Subtarget.hasSSE1();
bool HasAVX = Subtarget.hasAVX();
bool HasAVX512 = Subtarget.hasAVX512();
bool CallsEHReturn = MF->callsEHReturn();
- CallingConv::ID CC = MF->getFunction()->getCallingConv();
+ CallingConv::ID CC = F->getCallingConv();
// If attribute NoCallerSavedRegisters exists then we set X86_INTR calling
// convention because it has the CSR list.
@@ -365,22 +366,20 @@ X86RegisterInfo::getCalleeSavedRegs(cons
}
if (Is64Bit) {
- if (IsWin64) {
- if (!HasSSE)
- return CSR_Win64_NoSSE_SaveList;
- return CSR_Win64_SaveList;
- }
+ bool IsSwiftCC = Subtarget.getTargetLowering()->supportSwiftError() &&
+ F->getAttributes().hasAttrSomewhere(Attribute::SwiftError);
+ if (IsSwiftCC)
+ return IsWin64 ? CSR_Win64_SwiftError_SaveList
+ : CSR_64_SwiftError_SaveList;
+
+ if (IsWin64)
+ return HasSSE ? CSR_Win64_SaveList : CSR_Win64_NoSSE_SaveList;
if (CallsEHReturn)
return CSR_64EHRet_SaveList;
- if (Subtarget.getTargetLowering()->supportSwiftError() &&
- MF->getFunction()->getAttributes().hasAttrSomewhere(
- Attribute::SwiftError))
- return CSR_64_SwiftError_SaveList;
return CSR_64_SaveList;
}
- if (CallsEHReturn)
- return CSR_32EHRet_SaveList;
- return CSR_32_SaveList;
+
+ return CallsEHReturn ? CSR_32EHRet_SaveList : CSR_32_SaveList;
}
const MCPhysReg *X86RegisterInfo::getCalleeSavedRegsViaCopy(
@@ -479,14 +478,14 @@ X86RegisterInfo::getCallPreservedMask(co
// Unlike getCalleeSavedRegs(), we don't have MMI so we can't check
// callsEHReturn().
if (Is64Bit) {
- if (IsWin64)
- return CSR_Win64_RegMask;
- if (Subtarget.getTargetLowering()->supportSwiftError() &&
- MF.getFunction()->getAttributes().hasAttrSomewhere(
- Attribute::SwiftError))
- return CSR_64_SwiftError_RegMask;
- return CSR_64_RegMask;
+ const Function *F = MF.getFunction();
+ bool IsSwiftCC = Subtarget.getTargetLowering()->supportSwiftError() &&
+ F->getAttributes().hasAttrSomewhere(Attribute::SwiftError);
+ if (IsSwiftCC)
+ return IsWin64 ? CSR_Win64_SwiftError_RegMask : CSR_64_SwiftError_RegMask;
+ return IsWin64 ? CSR_Win64_RegMask : CSR_64_RegMask;
}
+
return CSR_32_RegMask;
}
Modified: llvm/trunk/test/CodeGen/X86/swift-error.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/swift-error.ll?rev=314165&r1=314164&r2=314165&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/swift-error.ll (original)
+++ llvm/trunk/test/CodeGen/X86/swift-error.ll Mon Sep 25 15:00:17 2017
@@ -11,8 +11,8 @@ entry:
}
; CHECK-LABEL: g
-; CHECK: pushq %r12
+; CHECK-NOT: pushq %r12
; CHECK: callq f
-; CHECK: popq %r12
+; CHECK-NOT: popq %r12
; CHECK: retq
More information about the llvm-commits
mailing list