llvm.org GIT mirror llvm / 42b983d
[X86] Fix the lowering of TLS calls. The callseq_end node must be glued with the TLS calls, otherwise, the generic code will miss the uses of the returned value and will mark it dead. Moreover, TLSCall 64-bit pseudo must not set an implicit-use on RDI, the pseudo uses the symbol address at this point not RDI and the lowering will do the right thing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267797 91177308-0d34-0410-b5e6-96231b3b80d8 Quentin Colombet 3 years ago
4 changed file(s) with 18 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
1295112951 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(0, DL, true), DL);
1295212952 SDValue Args[] = { Chain, Offset };
1295312953 Chain = DAG.getNode(X86ISD::TLSCALL, DL, NodeTys, Args);
12954 Chain =
12955 DAG.getCALLSEQ_END(Chain, DAG.getIntPtrConstant(0, DL, true),
12956 DAG.getIntPtrConstant(0, DL, true), SDValue(), DL);
12954 Chain = DAG.getCALLSEQ_END(Chain, DAG.getIntPtrConstant(0, DL, true),
12955 DAG.getIntPtrConstant(0, DL, true),
12956 Chain.getValue(1), DL);
1295712957
1295812958 // TLSCALL will be codegen'ed as call. Inform MFI that function has calls.
1295912959 MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo();
489489 [(X86TLSCall addr:$sym)]>,
490490 Requires<[Not64BitMode]>;
491491
492 // For x86_64, the address of the thunk is passed in %rdi, on return
493 // the address of the variable is in %rax. All other registers are preserved.
492 // For x86_64, the address of the thunk is passed in %rdi, but the
493 // pseudo directly use the symbol, so do not add an implicit use of
494 // %rdi. The lowering will do the right thing with RDI.
495 // On return the address of the variable is in %rax. All other
496 // registers are preserved.
494497 let Defs = [RAX, EFLAGS],
495 Uses = [RSP, RDI],
498 Uses = [RSP],
496499 usesCustomInserter = 1 in
497500 def TLSCall_64 : I<0, Pseudo, (outs), (ins i64mem:$sym),
498501 "# TLSCall_64",
None ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
0 ; RUN: llc -verify-machineinstrs < %s -mtriple=x86_64-apple-darwin | FileCheck %s
11 ; TLS function were wrongly model and after fixing that, shrink-wrapping
22 ; cannot help here. To achieve the expected lowering, we need to playing
33 ; tricks similar to AArch64 fast TLS calling convention (r255821).
99 ; PR26485.
1010 ;
1111 ; CHECK-LABEL: f:
12 ; Get c.
13 ; C is spilled because of the scheduling of the instructions,
14 ; but a smarter regalloc wouldn't have spilled it.
15 ; CHECK: movl L_c{{[^,]*}}, [[C_ADDR:%[a-z]+]]
16 ; CHECK-NEXT: movl [[C_ADDR]], [[C_SPILLED:[0-8]+\(%esp\)]]
1217 ; Get p.
13 ; CHECK: movl _p@{{[0-9a-zA-Z]+}}, [[P_ADDR:%[a-z]+]]
18 ; CHECK-NEXT: movl _p@{{[0-9a-zA-Z]+}}, [[P_ADDR:%[a-z]+]]
1419 ; CHECK-NEXT: calll *([[P_ADDR]])
1520 ; At this point eax contiains the address of p.
1621 ; Load c address.
1722 ; Make sure we do not clobber eax.
18 ; CHECK-NEXT: movl L_c{{[^,]*}}, [[C_ADDR:%e[b-z]x+]]
23 ; CHECK-NEXT: movl [[C_SPILLED]], [[C_ADDR_RELOADED:%e[b-z]x+]]
1924 ; Store c address into p.
20 ; CHECK-NEXT: movl [[C_ADDR]], (%eax)
25 ; CHECK-NEXT: movl [[C_ADDR_RELOADED]], (%eax)
2126 define void @f() #0 {
2227 entry:
2328 store i8* @c, i8** @p, align 4