summaryrefslogtreecommitdiffstats
path: root/llvm/test/ExecutionEngine
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2018-06-25 18:16:27 +0000
committerReid Kleckner <rnk@google.com>2018-06-25 18:16:27 +0000
commit88fee5fdbc2a4769f1f9428e4d4017815aef1849 (patch)
tree6ad5e61da7fd03725892c5a429d610b025a2bfd9 /llvm/test/ExecutionEngine
parentb8128476470836c8aeecdf4c2eea25077c36eea1 (diff)
downloadbcm5719-llvm-88fee5fdbc2a4769f1f9428e4d4017815aef1849.tar.gz
bcm5719-llvm-88fee5fdbc2a4769f1f9428e4d4017815aef1849.zip
Re-land r335297 "[X86] Implement more of x86-64 large and medium PIC code models"
The large code model allows code and data segments to exceed 2GB, which means that some symbol references may require a displacement that cannot be encoded as a displacement from RIP. The large PIC model even relaxes the assumption that the GOT itself is within 2GB of all code. Therefore, we need a special code sequence to materialize it: .LtmpN: leaq .LtmpN(%rip), %rbx movabsq $_GLOBAL_OFFSET_TABLE_-.LtmpN, %rax # Scratch addq %rax, %rbx # GOT base reg From that, non-local references go through the GOT base register instead of being PC-relative loads. Local references typically use GOTOFF symbols, like this: movq extern_gv@GOT(%rbx), %rax movq local_gv@GOTOFF(%rbx), %rax All calls end up being indirect: movabsq $local_fn@GOTOFF, %rax addq %rbx, %rax callq *%rax The medium code model retains the assumption that the code segment is less than 2GB, so calls are once again direct, and the RIP-relative loads can be used to access the GOT. Materializing the GOT is easy: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rbx # GOT base reg DSO local data accesses will use it: movq local_gv@GOTOFF(%rbx), %rax Non-local data accesses will use RIP-relative addressing, which means we may not always need to materialize the GOT base: movq extern_gv@GOTPCREL(%rip), %rax Direct calls are basically the same as they are in the small code model: They use direct, PC-relative addressing, and the PLT is used for calls to non-local functions. This patch adds reasonably comprehensive testing of LEA, but there are lots of interesting folding opportunities that are unimplemented. I restricted the MCJIT/eh-lg-pic.ll test to Linux, since the large PIC code model is not implemented for MachO yet. Differential Revision: https://reviews.llvm.org/D47211 llvm-svn: 335508
Diffstat (limited to 'llvm/test/ExecutionEngine')
-rw-r--r--llvm/test/ExecutionEngine/MCJIT/eh-lg-pic.ll10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/test/ExecutionEngine/MCJIT/eh-lg-pic.ll b/llvm/test/ExecutionEngine/MCJIT/eh-lg-pic.ll
index b5b9d5409c5..4dd9d2eeac1 100644
--- a/llvm/test/ExecutionEngine/MCJIT/eh-lg-pic.ll
+++ b/llvm/test/ExecutionEngine/MCJIT/eh-lg-pic.ll
@@ -1,6 +1,6 @@
-; REQUIRES: cxx-shared-library
+; REQUIRES: cxx-shared-library, system-linux
; RUN: %lli -relocation-model=pic -code-model=large %s
-; XFAIL: cygwin, win32, mingw, mips-, mipsel-, i686, i386, aarch64, arm
+; XFAIL: mips-, mipsel-, i686, i386, aarch64, arm
declare i8* @__cxa_allocate_exception(i64)
declare void @__cxa_throw(i8*, i8*, i8*)
declare i32 @__gxx_personality_v0(...)
@@ -15,8 +15,14 @@ define void @throwException() {
unreachable
}
+; Make an internal function so we exercise R_X86_64_GOTOFF64 relocations.
+define internal dso_local void @use_gotoff() {
+ ret void
+}
+
define i32 @main() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
entry:
+ call void @use_gotoff()
invoke void @throwException()
to label %try.cont unwind label %lpad
OpenPOWER on IntegriCloud