[llvm] r225438 - [X86] Don't try to generate direct calls to TLS globals
Michael Kuperstein
michael.m.kuperstein at intel.com
Thu Jan 8 03:50:59 PST 2015
Author: mkuper
Date: Thu Jan 8 05:50:58 2015
New Revision: 225438
URL: http://llvm.org/viewvc/llvm-project?rev=225438&view=rev
Log:
[X86] Don't try to generate direct calls to TLS globals
The call lowering assumes that if the callee is a global, we want to emit a direct call.
This is correct for regular globals, but not for TLS ones.
Differential Revision: http://reviews.llvm.org/D6862
Added:
llvm/trunk/test/CodeGen/X86/pr22103.ll
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=225438&r1=225437&r2=225438&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Jan 8 05:50:58 2015
@@ -3083,10 +3083,11 @@ X86TargetLowering::LowerCall(TargetLower
// through a register, since the call instruction's 32-bit
// pc-relative offset may not be large enough to hold the whole
// address.
- } else if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
+ } else if (Callee->getOpcode() == ISD::GlobalAddress) {
// If the callee is a GlobalAddress node (quite common, every direct call
// is) turn it into a TargetGlobalAddress node so that legalize doesn't hack
// it.
+ GlobalAddressSDNode* G = cast<GlobalAddressSDNode>(Callee);
// We should use extra load for direct calls to dllimported functions in
// non-JIT mode.
Added: llvm/trunk/test/CodeGen/X86/pr22103.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr22103.ll?rev=225438&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/pr22103.ll (added)
+++ llvm/trunk/test/CodeGen/X86/pr22103.ll Thu Jan 8 05:50:58 2015
@@ -0,0 +1,19 @@
+; RUN: llc < %s | FileCheck %s
+; Don't try to emit a direct call through a TLS global.
+; This fixes PR22103
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at a = external thread_local global i64
+
+; Function Attrs: nounwind
+define void @_Z1fv() {
+; CHECK-NOT: callq *$a
+; CHECK: movq %fs:0, [[RAX:%r..]]
+; CHECK-NEXT: addq a at GOTTPOFF(%rip), [[RAX]]
+; CHECK-NEXT: callq *%rax
+entry:
+ call void bitcast (i64* @a to void ()*)()
+ ret void
+}
More information about the llvm-commits
mailing list