[llvm-commits] [llvm] r52139 - in /llvm/trunk: lib/Target/X86/X86ATTAsmPrinter.cpp test/CodeGen/X86/x86-64-pic-1.ll test/CodeGen/X86/x86-64-pic-10.ll test/CodeGen/X86/x86-64-pic-11.ll test/CodeGen/X86/x86-64-pic-2.ll test/CodeGen/X86/x86-64-pic-3.ll test/CodeGen/X86/x86-64-pic-4.ll test/CodeGen/X86/x86-64-pic-5.ll test/CodeGen/X86/x86-64-pic-6.ll test/CodeGen/X86/x86-64-pic-7.ll test/CodeGen/X86/x86-64-pic-8.ll test/CodeGen/X86/x86-64-pic-9.ll
Rafael Espindola
rafael.espindola at gmail.com
Mon Jun 9 02:52:38 PDT 2008
Author: rafael
Date: Mon Jun 9 04:52:31 2008
New Revision: 52139
URL: http://llvm.org/viewvc/llvm-project?rev=52139&view=rev
Log:
add support for PIC on linux x86-64
Added:
llvm/trunk/test/CodeGen/X86/x86-64-pic-1.ll
llvm/trunk/test/CodeGen/X86/x86-64-pic-10.ll
llvm/trunk/test/CodeGen/X86/x86-64-pic-11.ll
llvm/trunk/test/CodeGen/X86/x86-64-pic-2.ll
llvm/trunk/test/CodeGen/X86/x86-64-pic-3.ll
llvm/trunk/test/CodeGen/X86/x86-64-pic-4.ll
llvm/trunk/test/CodeGen/X86/x86-64-pic-5.ll
llvm/trunk/test/CodeGen/X86/x86-64-pic-6.ll
llvm/trunk/test/CodeGen/X86/x86-64-pic-7.ll
llvm/trunk/test/CodeGen/X86/x86-64-pic-8.ll
llvm/trunk/test/CodeGen/X86/x86-64-pic-9.ll
Modified:
llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp
Modified: llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp?rev=52139&r1=52138&r2=52139&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp Mon Jun 9 04:52:31 2008
@@ -197,11 +197,16 @@
return false;
}
-static inline bool printGOT(TargetMachine &TM, const X86Subtarget* ST) {
+static inline bool shouldPrintGOT(TargetMachine &TM, const X86Subtarget* ST) {
return ST->isPICStyleGOT() && TM.getRelocationModel() == Reloc::PIC_;
}
-static inline bool printStub(TargetMachine &TM, const X86Subtarget* ST) {
+static inline bool shouldPrintPLT(TargetMachine &TM, const X86Subtarget* ST) {
+ return ST->isTargetELF() && TM.getRelocationModel() == Reloc::PIC_ &&
+ (ST->isPICStyleRIPRel() || ST->isPICStyleGOT());
+}
+
+static inline bool shouldPrintStub(TargetMachine &TM, const X86Subtarget* ST) {
return ST->isPICStyleStub() && TM.getRelocationModel() != Reloc::Static;
}
@@ -304,7 +309,7 @@
needCloseParen = true;
}
- if (printStub(TM, Subtarget)) {
+ if (shouldPrintStub(TM, Subtarget)) {
// Link-once, declaration, or Weakly-linked global variables need
// non-lazily-resolved stubs
if (GV->isDeclaration() ||
@@ -333,11 +338,11 @@
}
O << Name;
- if (isCallOp && isa<Function>(GV)) {
- if (printGOT(TM, Subtarget)) {
- // Assemble call via PLT for non-local symbols
- if (!(GV->hasHiddenVisibility() || GV->hasProtectedVisibility()) ||
- GV->isDeclaration())
+ if (isCallOp) {
+ if (shouldPrintPLT(TM, Subtarget)) {
+ // Assemble call via PLT for externally visible symbols
+ if (!GV->hasHiddenVisibility() && !GV->hasProtectedVisibility() &&
+ !GV->hasInternalLinkage())
O << "@PLT";
}
if (Subtarget->isTargetCygMing() && GV->isDeclaration())
@@ -364,7 +369,7 @@
else
O << "@NTPOFF"; // local exec TLS model
} else if (isMemOp) {
- if (printGOT(TM, Subtarget)) {
+ if (shouldPrintGOT(TM, Subtarget)) {
if (Subtarget->GVRequiresExtraLoad(GV, TM, false))
O << "@GOT";
else
@@ -396,7 +401,7 @@
bool needCloseParen = false;
std::string Name(TAI->getGlobalPrefix());
Name += MO.getSymbolName();
- if (isCallOp && printStub(TM, Subtarget)) {
+ if (isCallOp && shouldPrintStub(TM, Subtarget)) {
FnStubs.insert(Name);
printSuffixedName(Name, "$stub");
return;
@@ -412,7 +417,7 @@
O << Name;
- if (printGOT(TM, Subtarget)) {
+ if (shouldPrintPLT(TM, Subtarget)) {
std::string GOTName(TAI->getGlobalPrefix());
GOTName+="_GLOBAL_OFFSET_TABLE_";
if (Name == GOTName)
@@ -646,4 +651,3 @@
// Include the auto-generated portion of the assembly writer.
#include "X86GenAsmWriter.inc"
-
Added: llvm/trunk/test/CodeGen/X86/x86-64-pic-1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-pic-1.ll?rev=52139&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/x86-64-pic-1.ll (added)
+++ llvm/trunk/test/CodeGen/X86/x86-64-pic-1.ll Mon Jun 9 04:52:31 2008
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s | \
+; RUN: llc -mtriple=x86_64-pc-linux -relocation-model=pic -o %t1 -f
+; RUN: grep {call f at PLT} %t1
+
+define void @g() {
+entry:
+ call void @f( )
+ ret void
+}
+
+declare void @f()
Added: llvm/trunk/test/CodeGen/X86/x86-64-pic-10.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-pic-10.ll?rev=52139&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/x86-64-pic-10.ll (added)
+++ llvm/trunk/test/CodeGen/X86/x86-64-pic-10.ll Mon Jun 9 04:52:31 2008
@@ -0,0 +1,13 @@
+; RUN: llvm-as < %s | \
+; RUN: llc -mtriple=x86_64-pc-linux -relocation-model=pic -o %t1 -f
+; RUN: grep {call g at PLT} %t1
+
+ at g = alias weak i32 ()* @f
+
+define void @g() {
+entry:
+ %tmp31 = call i32 @g()
+ ret void
+}
+
+declare extern_weak i32 @f()
Added: llvm/trunk/test/CodeGen/X86/x86-64-pic-11.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-pic-11.ll?rev=52139&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/x86-64-pic-11.ll (added)
+++ llvm/trunk/test/CodeGen/X86/x86-64-pic-11.ll Mon Jun 9 04:52:31 2008
@@ -0,0 +1,9 @@
+; RUN: llvm-as < %s | \
+; RUN: llc -mtriple=x86_64-pc-linux -relocation-model=pic -o %t1 -f
+; RUN: grep {call __fixunsxfti at PLT} %t1
+
+define i128 @f(x86_fp80 %a) {
+entry:
+ %tmp78 = fptoui x86_fp80 %a to i128
+ ret i128 %tmp78
+}
Added: llvm/trunk/test/CodeGen/X86/x86-64-pic-2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-pic-2.ll?rev=52139&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/x86-64-pic-2.ll (added)
+++ llvm/trunk/test/CodeGen/X86/x86-64-pic-2.ll Mon Jun 9 04:52:31 2008
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s | \
+; RUN: llc -mtriple=x86_64-pc-linux -relocation-model=pic -o %t1 -f
+; RUN: grep {call f} %t1
+; RUN: not grep {call f at PLT} %t1
+
+define void @g() {
+entry:
+ call void @f( )
+ ret void
+}
+
+declare hidden void @f()
Added: llvm/trunk/test/CodeGen/X86/x86-64-pic-3.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-pic-3.ll?rev=52139&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/x86-64-pic-3.ll (added)
+++ llvm/trunk/test/CodeGen/X86/x86-64-pic-3.ll Mon Jun 9 04:52:31 2008
@@ -0,0 +1,15 @@
+; RUN: llvm-as < %s | \
+; RUN: llc -mtriple=x86_64-pc-linux -relocation-model=pic -o %t1 -f
+; RUN: grep {call f} %t1
+; RUN: not grep {call f at PLT} %t1
+
+define void @g() {
+entry:
+ call void @f( )
+ ret void
+}
+
+define internal void @f() {
+entry:
+ ret void
+}
Added: llvm/trunk/test/CodeGen/X86/x86-64-pic-4.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-pic-4.ll?rev=52139&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/x86-64-pic-4.ll (added)
+++ llvm/trunk/test/CodeGen/X86/x86-64-pic-4.ll Mon Jun 9 04:52:31 2008
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s | \
+; RUN: llc -mtriple=x86_64-pc-linux -relocation-model=pic -o %t1 -f
+; RUN: grep {movq a at GOTPCREL(%rip),} %t1
+
+ at a = global i32 0
+
+define i32 @get_a() {
+entry:
+ %tmp1 = load i32* @a, align 4
+ ret i32 %tmp1
+}
Added: llvm/trunk/test/CodeGen/X86/x86-64-pic-5.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-pic-5.ll?rev=52139&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/x86-64-pic-5.ll (added)
+++ llvm/trunk/test/CodeGen/X86/x86-64-pic-5.ll Mon Jun 9 04:52:31 2008
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s | \
+; RUN: llc -mtriple=x86_64-pc-linux -relocation-model=pic -o %t1 -f
+; RUN: grep {movl a(%rip),} %t1
+; RUN: not grep GOTPCREL %t1
+
+ at a = hidden global i32 0
+
+define i32 @get_a() {
+entry:
+ %tmp1 = load i32* @a, align 4
+ ret i32 %tmp1
+}
Added: llvm/trunk/test/CodeGen/X86/x86-64-pic-6.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-pic-6.ll?rev=52139&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/x86-64-pic-6.ll (added)
+++ llvm/trunk/test/CodeGen/X86/x86-64-pic-6.ll Mon Jun 9 04:52:31 2008
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s | \
+; RUN: llc -mtriple=x86_64-pc-linux -relocation-model=pic -o %t1 -f
+; RUN: grep {movl a(%rip),} %t1
+; RUN: not grep GOTPCREL %t1
+
+ at a = internal global i32 0
+
+define i32 @get_a() {
+entry:
+ %tmp1 = load i32* @a, align 4
+ ret i32 %tmp1
+}
Added: llvm/trunk/test/CodeGen/X86/x86-64-pic-7.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-pic-7.ll?rev=52139&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/x86-64-pic-7.ll (added)
+++ llvm/trunk/test/CodeGen/X86/x86-64-pic-7.ll Mon Jun 9 04:52:31 2008
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | \
+; RUN: llc -mtriple=x86_64-pc-linux -relocation-model=pic -o %t1 -f
+; RUN: grep {movq f at GOTPCREL(%rip),} %t1
+
+define void ()* @g() {
+entry:
+ ret void ()* @f
+}
+
+declare void @f()
Added: llvm/trunk/test/CodeGen/X86/x86-64-pic-8.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-pic-8.ll?rev=52139&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/x86-64-pic-8.ll (added)
+++ llvm/trunk/test/CodeGen/X86/x86-64-pic-8.ll Mon Jun 9 04:52:31 2008
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s | \
+; RUN: llc -mtriple=x86_64-pc-linux -relocation-model=pic -o %t1 -f
+; RUN: grep {leaq f(%rip),} %t1
+; RUN: not grep GOTPCREL %t1
+
+define void ()* @g() {
+entry:
+ ret void ()* @f
+}
+
+declare hidden void @f()
Added: llvm/trunk/test/CodeGen/X86/x86-64-pic-9.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-pic-9.ll?rev=52139&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/x86-64-pic-9.ll (added)
+++ llvm/trunk/test/CodeGen/X86/x86-64-pic-9.ll Mon Jun 9 04:52:31 2008
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | \
+; RUN: llc -mtriple=x86_64-pc-linux -relocation-model=pic -o %t1 -f
+; RUN: grep {leaq f(%rip),} %t1
+; RUN: not grep GOTPCREL %t1
+
+define void ()* @g() {
+entry:
+ ret void ()* @f
+}
+
+define internal void @f() {
+entry:
+ ret void
+}
More information about the llvm-commits
mailing list