[llvm] [X86] Insert CALLSEQ when lowering GlobalTLSAddress for ELF targets (PR #113706)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 25 16:19:47 PDT 2024


================
@@ -18852,13 +18870,20 @@ GetTLSADDR(SelectionDAG &DAG, SDValue Chain, GlobalAddressSDNode *GA,
                               : LocalDynamic ? X86ISD::TLSBASEADDR
                                              : X86ISD::TLSADDR;
 
-  if (InGlue) {
-    SDValue Ops[] = { Chain,  TGA, *InGlue };
+  Chain = DAG.getCALLSEQ_START(Chain, 0, 0, dl);
+  if (LoadGlobalBaseReg) {
+    SDValue InGlue;
+    Chain = DAG.getCopyToReg(Chain, dl, X86::EBX,
+                             DAG.getNode(X86ISD::GlobalBaseReg, SDLoc(), PtrVT),
+                             InGlue);
+    InGlue = Chain.getValue(1);
+    SDValue Ops[] = {Chain, TGA, InGlue};
     Chain = DAG.getNode(CallType, dl, NodeTys, Ops);
   } else {
-    SDValue Ops[]  = { Chain, TGA };
+    SDValue Ops[] = {Chain, TGA};
     Chain = DAG.getNode(CallType, dl, NodeTys, Ops);
   }
+  Chain = DAG.getCALLSEQ_END(Chain, 0, 0, Chain.getValue(1), dl);
 
   // TLSADDR will be codegen'ed as call. Inform MFI that function has calls.
----------------
arsenm wrote:

Is this redundant now? 

https://github.com/llvm/llvm-project/pull/113706


More information about the llvm-commits mailing list