From c07f5bbd3b3d93e087160c87f0e5be7419772687 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 7 Jun 2012 18:39:19 +0000 Subject: [PATCH] Use a base register instead of an index register with the local dynamic model. Fixes pr13048. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158158 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86MCInstLower.cpp | 8 ++++++++ test/CodeGen/X86/tls-pic.ll | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Target/X86/X86MCInstLower.cpp b/lib/Target/X86/X86MCInstLower.cpp index 9dc5c7035d4..df7507ce3d6 100644 --- a/lib/Target/X86/X86MCInstLower.cpp +++ b/lib/Target/X86/X86MCInstLower.cpp @@ -596,6 +596,14 @@ static void LowerTlsAddr(MCStreamer &OutStreamer, LEA.addOperand(MCOperand::CreateReg(0)); // index LEA.addOperand(MCOperand::CreateExpr(symRef)); // disp LEA.addOperand(MCOperand::CreateReg(0)); // seg + } else if (SRVK == MCSymbolRefExpr::VK_TLSLDM) { + LEA.setOpcode(X86::LEA32r); + LEA.addOperand(MCOperand::CreateReg(X86::EAX)); // dest + LEA.addOperand(MCOperand::CreateReg(X86::EBX)); // base + LEA.addOperand(MCOperand::CreateImm(1)); // scale + LEA.addOperand(MCOperand::CreateReg(0)); // index + LEA.addOperand(MCOperand::CreateExpr(symRef)); // disp + LEA.addOperand(MCOperand::CreateReg(0)); // seg } else { LEA.setOpcode(X86::LEA32r); LEA.addOperand(MCOperand::CreateReg(X86::EAX)); // dest diff --git a/test/CodeGen/X86/tls-pic.ll b/test/CodeGen/X86/tls-pic.ll index c3e82167256..51c3d2363f8 100644 --- a/test/CodeGen/X86/tls-pic.ll +++ b/test/CodeGen/X86/tls-pic.ll @@ -75,7 +75,7 @@ entry: } ; X32: f5: -; X32: leal {{[jk]}}@TLSLDM +; X32: leal {{[jk]}}@TLSLDM(%ebx) ; X32-NEXT: calll ___tls_get_addr@PLT ; X32-NEXT: movl {{[jk]}}@DTPOFF(%eax) ; X32-NEXT: addl {{[jk]}}@DTPOFF(%eax)