summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-04-22 20:40:10 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-04-22 20:40:10 +0000
commit265ebd7d70496049d49021b4eb5eabffcf291b7d (patch)
tree4812863753534f9ff90358e0e120efa8bbcac6b8 /llvm/test
parenteedef73b633496ca52af265b472519f0e385a7d2 (diff)
downloadbcm5719-llvm-265ebd7d70496049d49021b4eb5eabffcf291b7d.tar.gz
bcm5719-llvm-265ebd7d70496049d49021b4eb5eabffcf291b7d.zip
CodeGen: Use PLT relocations for relative references to unnamed_addr functions.
The relative vtable ABI (PR26723) needs PLT relocations to refer to virtual functions defined in other DSOs. The unnamed_addr attribute means that the function's address is not significant, so we're allowed to substitute it with the address of a PLT entry. Also includes a bonus feature: addends for COFF image-relative references. Differential Revision: http://reviews.llvm.org/D17938 llvm-svn: 267211
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/ARM/plt-relative-reloc.ll16
-rw-r--r--llvm/test/CodeGen/X86/x86-64-plt-relative-reloc.ll19
-rw-r--r--llvm/test/CodeGen/X86/x86-plt-relative-reloc.ll16
-rw-r--r--llvm/test/MC/COFF/cross-section-relative.ll11
-rw-r--r--llvm/test/MC/MachO/AArch64/cstexpr-gotpcrel.ll2
5 files changed, 59 insertions, 5 deletions
diff --git a/llvm/test/CodeGen/ARM/plt-relative-reloc.ll b/llvm/test/CodeGen/ARM/plt-relative-reloc.ll
new file mode 100644
index 00000000000..08dcfdf1298
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/plt-relative-reloc.ll
@@ -0,0 +1,16 @@
+; RUN: llc -mtriple=armv7-unknown-linux -o - %s | FileCheck %s
+
+@vtable = constant [4 x i32] [i32 0,
+ i32 sub (i32 ptrtoint (void ()* @fn1 to i32), i32 ptrtoint (i32* getelementptr ([4 x i32], [4 x i32]* @vtable, i32 0, i32 1) to i32)),
+ i32 sub (i32 ptrtoint (void ()* @fn2 to i32), i32 ptrtoint (i32* getelementptr ([4 x i32], [4 x i32]* @vtable, i32 0, i32 1) to i32)),
+ i32 sub (i32 ptrtoint (void ()* @fn3 to i32), i32 ptrtoint (i32* getelementptr ([4 x i32], [4 x i32]* @vtable, i32 0, i32 1) to i32))
+]
+
+declare void @fn1() unnamed_addr
+declare void @fn2() unnamed_addr
+declare void @fn3()
+
+; CHECK: .long 0
+; CHECK-NEXT: .long (fn1(prel31)-vtable)-4
+; CHECK-NEXT: .long (fn2(prel31)-vtable)-4
+; CHECK-NEXT: .long (fn3-vtable)-4
diff --git a/llvm/test/CodeGen/X86/x86-64-plt-relative-reloc.ll b/llvm/test/CodeGen/X86/x86-64-plt-relative-reloc.ll
new file mode 100644
index 00000000000..8ba480d1e1d
--- /dev/null
+++ b/llvm/test/CodeGen/X86/x86-64-plt-relative-reloc.ll
@@ -0,0 +1,19 @@
+; RUN: llc -mtriple=x86_64-unknown-linux -o - %s | FileCheck %s
+
+@vtable = constant [5 x i32] [i32 0,
+ i32 trunc (i64 sub (i64 ptrtoint (void ()* @fn1 to i64), i64 ptrtoint (i32* getelementptr ([5 x i32], [5 x i32]* @vtable, i32 0, i32 1) to i64)) to i32),
+ i32 trunc (i64 sub (i64 ptrtoint (void ()* @fn2 to i64), i64 ptrtoint (i32* getelementptr ([5 x i32], [5 x i32]* @vtable, i32 0, i32 1) to i64)) to i32),
+ i32 trunc (i64 sub (i64 ptrtoint (void ()* @fn3 to i64), i64 ptrtoint (i32* getelementptr ([5 x i32], [5 x i32]* @vtable, i32 0, i32 1) to i64)) to i32),
+ i32 trunc (i64 sub (i64 ptrtoint (i8* @global4 to i64), i64 ptrtoint (i32* getelementptr ([5 x i32], [5 x i32]* @vtable, i32 0, i32 1) to i64)) to i32)
+]
+
+declare void @fn1() unnamed_addr
+declare void @fn2() unnamed_addr
+declare void @fn3()
+@global4 = external unnamed_addr global i8
+
+; CHECK: .long 0
+; CHECK-NEXT: .long (fn1@PLT-vtable)-4
+; CHECK-NEXT: .long (fn2@PLT-vtable)-4
+; CHECK-NEXT: .long (fn3-vtable)-4
+; CHECK-NEXT: .long (global4-vtable)-4
diff --git a/llvm/test/CodeGen/X86/x86-plt-relative-reloc.ll b/llvm/test/CodeGen/X86/x86-plt-relative-reloc.ll
new file mode 100644
index 00000000000..733a4cb5f03
--- /dev/null
+++ b/llvm/test/CodeGen/X86/x86-plt-relative-reloc.ll
@@ -0,0 +1,16 @@
+; RUN: llc -mtriple=i686-unknown-linux -o - %s | FileCheck %s
+
+@vtable = constant [4 x i32] [i32 0,
+ i32 sub (i32 ptrtoint (void ()* @fn1 to i32), i32 ptrtoint (i32* getelementptr ([4 x i32], [4 x i32]* @vtable, i32 0, i32 1) to i32)),
+ i32 sub (i32 ptrtoint (void ()* @fn2 to i32), i32 ptrtoint (i32* getelementptr ([4 x i32], [4 x i32]* @vtable, i32 0, i32 1) to i32)),
+ i32 sub (i32 ptrtoint (void ()* @fn3 to i32), i32 ptrtoint (i32* getelementptr ([4 x i32], [4 x i32]* @vtable, i32 0, i32 1) to i32))
+]
+
+declare void @fn1() unnamed_addr
+declare void @fn2() unnamed_addr
+declare void @fn3()
+
+; CHECK: .long 0
+; CHECK-NEXT: .long (fn1@PLT-vtable)-4
+; CHECK-NEXT: .long (fn2@PLT-vtable)-4
+; CHECK-NEXT: .long (fn3-vtable)-4
diff --git a/llvm/test/MC/COFF/cross-section-relative.ll b/llvm/test/MC/COFF/cross-section-relative.ll
index 6b7a3d7b40b..724b1a0a426 100644
--- a/llvm/test/MC/COFF/cross-section-relative.ll
+++ b/llvm/test/MC/COFF/cross-section-relative.ll
@@ -22,16 +22,19 @@
;;;; image base relocation
-; CHECK: .long g3@IMGREL
+; CHECK: .long g3@IMGREL{{$}}
@t5 = global i32 trunc(i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i64** @__ImageBase to i64)) to i32), section ".fix"
+; CHECK: .long g3@IMGREL+4{{$}}
+@t6 = global i32 trunc(i64 sub(i64 ptrtoint(i32* getelementptr (i32, i32* @g3, i32 1) to i64), i64 ptrtoint(i64** @__ImageBase to i64)) to i32), section ".fix"
+
;;;; cross-section relative with source offset
%struct.EEType = type { [2 x i8], i64, i32}
-; CHECK: .long g3-(t6+16)
-@t6 = global %struct.EEType {
+; CHECK: .long (g3-t7)-16
+@t7 = global %struct.EEType {
[2 x i8] c"\01\02",
i64 256,
- i32 trunc(i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i32* getelementptr inbounds (%struct.EEType, %struct.EEType* @t6, i32 0, i32 2) to i64)) to i32 )
+ i32 trunc(i64 sub(i64 ptrtoint(i32* @g3 to i64), i64 ptrtoint(i32* getelementptr inbounds (%struct.EEType, %struct.EEType* @t7, i32 0, i32 2) to i64)) to i32 )
}, section ".fix"
diff --git a/llvm/test/MC/MachO/AArch64/cstexpr-gotpcrel.ll b/llvm/test/MC/MachO/AArch64/cstexpr-gotpcrel.ll
index 7a4f33ba0bf..0cfb764a835 100644
--- a/llvm/test/MC/MachO/AArch64/cstexpr-gotpcrel.ll
+++ b/llvm/test/MC/MachO/AArch64/cstexpr-gotpcrel.ll
@@ -49,7 +49,7 @@
; supported on x86-64 but not on ARM64
; CHECK: .long 5
-; CHECK-NEXT: .long (l_extgotequiv-(_table+44))+24
+; CHECK-NEXT: .long ((l_extgotequiv-_table)-44)+24
%struct.data { i32 4, %struct.anon { i32 5,
i32 add (i32 trunc (i64 sub (i64 ptrtoint (i32** @extgotequiv to i64),
i64 ptrtoint (i32* getelementptr inbounds ([4 x %struct.data], [4 x %struct.data]* @table, i32 0, i64 3, i32 1, i32 1) to i64))
OpenPOWER on IntegriCloud