[PATCH] D13481: [X86] Call locally defined function directly for PIE
H.J Lu via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 9 09:28:41 PDT 2015
hjl.tools removed rL LLVM as the repository for this revision.
hjl.tools updated this revision to Diff 36958.
hjl.tools added a comment.
Update to a single testcase with
; LINUX: call{{l|q}} foo{{$}}
http://reviews.llvm.org/D13481
Files:
lib/Target/X86/X86FastISel.cpp
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/pie.ll
Index: test/CodeGen/X86/pie.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/pie.ll
@@ -0,0 +1,27 @@
+; RUN: llc < %s -mcpu=generic -mtriple=i686-linux-gnu -relocation-model=pic -asm-verbose=false -enable-pie | FileCheck %s -check-prefix=LINUX
+; RUN: llc < %s -mcpu=generic -mtriple=i686-linux-gnu -fast-isel -relocation-model=pic -asm-verbose=false -enable-pie | FileCheck %s -check-prefix=LINUX
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic -asm-verbose=false -enable-pie | FileCheck %s -check-prefix=LINUX
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnu -fast-isel -relocation-model=pic -asm-verbose=false -enable-pie | FileCheck %s -check-prefix=LINUX
+
+; LINUX: call{{l|q}} foo{{$}}
+
+ at glob = common global i32 0, align 4
+
+; Function Attrs: nounwind uwtable
+define i32 @foo() {
+entry:
+ %0 = load i32, i32* @glob, align 4
+ ret i32 %0
+}
+
+; Function Attrs: nounwind uwtable
+define void @bar() {
+entry:
+ %call = call i32 @foo()
+ store i32 %call, i32* @glob, align 4
+ ret void
+}
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 1, !"PIC Level", i32 2}
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -3310,6 +3310,8 @@
// we don't need to use the PLT - we can directly call it.
if (Subtarget->isTargetELF() &&
DAG.getTarget().getRelocationModel() == Reloc::PIC_ &&
+ !(DAG.getTarget().Options.PositionIndependentExecutable &&
+ GV->isStrongDefinitionForLinker()) &&
GV->hasDefaultVisibility() && !GV->hasLocalLinkage()) {
OpFlags = X86II::MO_PLT;
} else if (Subtarget->isPICStyleStubAny() &&
Index: lib/Target/X86/X86FastISel.cpp
===================================================================
--- lib/Target/X86/X86FastISel.cpp
+++ lib/Target/X86/X86FastISel.cpp
@@ -3088,6 +3088,8 @@
// we don't need to use the PLT - we can directly call it.
if (Subtarget->isTargetELF() &&
TM.getRelocationModel() == Reloc::PIC_ &&
+ !(TM.Options.PositionIndependentExecutable &&
+ GV->isStrongDefinitionForLinker()) &&
GV->hasDefaultVisibility() && !GV->hasLocalLinkage()) {
OpFlags = X86II::MO_PLT;
} else if (Subtarget->isPICStyleStubAny() &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13481.36958.patch
Type: text/x-patch
Size: 2425 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151009/1adbe3a6/attachment.bin>
More information about the llvm-commits
mailing list