llvm.org GIT mirror llvm / 6c3ce45
[TLS on Darwin] use a different mask for tls calls on x86-64. Calls involved in thread-local variable lookup save more registers than normal calls. rdar://problem/23073171 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252837 91177308-0d34-0410-b5e6-96231b3b80d8 Manman Ren 4 years ago
5 changed file(s) with 44 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
795795 def CSR_Win64 : CalleeSavedRegs<(add RBX, RBP, RDI, RSI, R12, R13, R14, R15,
796796 (sequence "XMM%u", 6, 15))>;
797797
798 // The function used by Darwin to obtain the address of a thread-local variable
799 // uses rdi to pass a single parameter and rax for the return value. All other
800 // GPRs are preserved.
801 def CSR_64_TLS_Darwin : CalleeSavedRegs<(add CSR_64, RCX, RDX, RSI,
802 R8, R9, R10, R11)>;
803
798804 // All GPRs - except r11
799805 def CSR_64_RT_MostRegs : CalleeSavedRegs<(add CSR_64, RAX, RCX, RDX, RSI, RDI,
800806 R8, R9, R10, RSP)>;
2146021460 // FIXME: The 32-bit calls have non-standard calling conventions. Use a
2146121461 // proper register mask.
2146221462 const uint32_t *RegMask =
21463 Subtarget->is64Bit() ?
21464 Subtarget->getRegisterInfo()->getDarwinTLSCallPreservedMask() :
2146321465 Subtarget->getRegisterInfo()->getCallPreservedMask(*F, CallingConv::C);
2146421466 if (Subtarget->is64Bit()) {
2146521467 MachineInstrBuilder MIB = BuildMI(*BB, MI, DL,
344344 const uint32_t*
345345 X86RegisterInfo::getNoPreservedMask() const {
346346 return CSR_NoRegs_RegMask;
347 }
348
349 const uint32_t *X86RegisterInfo::getDarwinTLSCallPreservedMask() const {
350 return CSR_64_TLS_Darwin_RegMask;
347351 }
348352
349353 BitVector X86RegisterInfo::getReservedRegs(const MachineFunction &MF) const {
9797 CallingConv::ID) const override;
9898 const uint32_t *getNoPreservedMask() const override;
9999
100 // Calls involved in thread-local variable lookup save more registers than
101 // normal calls, so they need a different mask to represent this.
102 const uint32_t *getDarwinTLSCallPreservedMask() const;
103
100104 /// getReservedRegs - Returns a bitset indexed by physical register number
101105 /// indicating if a register is a special register that has particular uses and
102106 /// should be considered unavailable at all times, e.g. SP, RA. This is used by
0 ; RUN: llc < %s -mtriple x86_64-apple-darwin | FileCheck %s
1
2 @a = thread_local global i32 4, align 4
3
4 define i32 @f2(i32 %p1, i32 %p2, i32 %p3, i32 %p4, i32 %p5) {
5 entry:
6 ; Parameters are in %edi, %esi, %edx, %ecx, %r8d, there is no need to save
7 ; these parameters except the one in %edi, before making the TLS call.
8 ; %edi is used to pass parameter to the TLS call.
9 ; CHECK-NOT: movl %r8d
10 ; CHECK-NOT: movl %ecx
11 ; CHECK-NOT: movl %edx
12 ; CHECK-NOT: movl %esi
13 ; CHECK: movq {{.*}}TLVP{{.*}}, %rdi
14 ; CHECK-NEXT: callq
15 ; CHECK-NEXT: movl (%rax),
16 ; CHECK-NOT: movl {{.*}}, %esi
17 ; CHECK-NOT: movl {{.*}}, %edx
18 ; CHECK-NOT: movl {{.*}}, %ecx
19 ; CHECK-NOT: movl {{.*}}, %r8d
20 ; CHECK: callq
21 %0 = load i32, i32* @a, align 4
22 %call = tail call i32 @f3(i32 %p1, i32 %p2, i32 %p3, i32 %p4, i32 %p5)
23 %add = add nsw i32 %call, %0
24 ret i32 %add
25 }
26
27 declare i32 @f3(i32, i32, i32, i32, i32)