diff options
| author | Jeffrey Yasskin <jyasskin@google.com> | 2009-12-13 20:30:32 +0000 |
|---|---|---|
| committer | Jeffrey Yasskin <jyasskin@google.com> | 2009-12-13 20:30:32 +0000 |
| commit | 8c17e6de2b291b006797f513b848dd7291332207 (patch) | |
| tree | 5a269501a51ec6bc17f615335c04f83a6fbcbcdf /llvm/unittests/ExecutionEngine/JIT | |
| parent | adbe4249d6a643a78720db059c946a608d7a8673 (diff) | |
| download | bcm5719-llvm-8c17e6de2b291b006797f513b848dd7291332207.tar.gz bcm5719-llvm-8c17e6de2b291b006797f513b848dd7291332207.zip | |
Reinstate r91208 to fix available_externally linkage for globals, with
nlewycky's fix to add -rdynamic so the JIT can look symbols up in Linux builds
of the JITTests binary.
llvm-svn: 91250
Diffstat (limited to 'llvm/unittests/ExecutionEngine/JIT')
| -rw-r--r-- | llvm/unittests/ExecutionEngine/JIT/JITTest.cpp | 25 | ||||
| -rw-r--r-- | llvm/unittests/ExecutionEngine/JIT/Makefile | 3 |
2 files changed, 28 insertions, 0 deletions
diff --git a/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp b/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp index 12c6b67d987..bbf34603872 100644 --- a/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp +++ b/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp @@ -534,6 +534,31 @@ TEST_F(JITTest, FunctionPointersOutliveTheirCreator) { #endif } +} // anonymous namespace +// This variable is intentionally defined differently in the statically-compiled +// program from the IR input to the JIT to assert that the JIT doesn't use its +// definition. +extern "C" int32_t JITTest_AvailableExternallyGlobal; +int32_t JITTest_AvailableExternallyGlobal = 42; +namespace { + +TEST_F(JITTest, AvailableExternallyGlobalIsntEmitted) { + TheJIT->DisableLazyCompilation(true); + LoadAssembly("@JITTest_AvailableExternallyGlobal = " + " available_externally global i32 7 " + " " + "define i32 @loader() { " + " %result = load i32* @JITTest_AvailableExternallyGlobal " + " ret i32 %result " + "} "); + Function *loaderIR = M->getFunction("loader"); + + int32_t (*loader)() = reinterpret_cast<int32_t(*)()>( + (intptr_t)TheJIT->getPointerToFunction(loaderIR)); + EXPECT_EQ(42, loader()) << "func should return 42 from the external global," + << " not 7 from the IR version."; +} + // This code is copied from JITEventListenerTest, but it only runs once for all // the tests in this directory. Everything seems fine, but that's strange // behavior. diff --git a/llvm/unittests/ExecutionEngine/JIT/Makefile b/llvm/unittests/ExecutionEngine/JIT/Makefile index 048924ae26d..8de390bf94a 100644 --- a/llvm/unittests/ExecutionEngine/JIT/Makefile +++ b/llvm/unittests/ExecutionEngine/JIT/Makefile @@ -13,3 +13,6 @@ LINK_COMPONENTS := asmparser core support jit native include $(LEVEL)/Makefile.config include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest + +# Permit these tests to use the JIT's symbolic lookup. +LD.Flags += $(RDYNAMIC) |

