CXX_FAST_TLS calling convention: fix issue on x86-64.

%RBP can't be handled explicitly. We generate the following code:
    pushq %rbp
    movq  %rsp, %rbp
    ...
    movq  %rbx, (%rbp)  ## 8-byte Spill
where %rbp will be overwritten by the spilled value.

The fix is to let PEI handle %RBP.
PR26136

llvm-svn: 257997
This commit is contained in:
Manman Ren 2016-01-16 16:39:46 +00:00
parent 8270fe5960
commit 53a54c41d7
2 changed files with 14 additions and 2 deletions

View File

@ -832,10 +832,10 @@ def CSR_64_TLS_Darwin : CalleeSavedRegs<(add CSR_64, RCX, RDX, RSI,
R8, R9, R10, R11)>;
// CSRs that are handled by prologue, epilogue.
def CSR_64_CXX_TLS_Darwin_PE : CalleeSavedRegs<(add)>;
def CSR_64_CXX_TLS_Darwin_PE : CalleeSavedRegs<(add RBP)>;
// CSRs that are handled explicitly via copies.
def CSR_64_CXX_TLS_Darwin_ViaCopy : CalleeSavedRegs<(add CSR_64_TLS_Darwin)>;
def CSR_64_CXX_TLS_Darwin_ViaCopy : CalleeSavedRegs<(sub CSR_64_TLS_Darwin, RBP)>;
// All GPRs - except r11
def CSR_64_RT_MostRegs : CalleeSavedRegs<(add CSR_64, RAX, RCX, RDX, RSI, RDI,

View File

@ -4,6 +4,7 @@
; tricks similar to AArch64 fast TLS calling convention (r255821).
; Applying tricks on x86-64 similar to r255821.
; RUN: llc < %s -mtriple=x86_64-apple-darwin -enable-shrink-wrap=true | FileCheck %s
; RUN: llc < %s -mtriple=x86_64-apple-darwin -O0 | FileCheck %s --check-prefix=CHECK-O0
%struct.S = type { i8 }
@sg = internal thread_local global %struct.S zeroinitializer, align 1
@ -65,3 +66,14 @@ __tls_init.exit:
define cxx_fast_tlscc nonnull i32* @_ZTW4sum1() nounwind {
ret i32* @sum1
}
; Make sure at O0 we don't overwrite RBP.
; CHECK-O0-LABEL: _ZTW4sum2
; CHECK-O0: pushq %rbp
; CHECK-O0: movq %rsp, %rbp
; CHECK-O0-NOT: movq %r{{.*}}, (%rbp)
define cxx_fast_tlscc i32* @_ZTW4sum2() #0 {
ret i32* @sum1
}
attributes #0 = { nounwind "no-frame-pointer-elim"="true" }