[llvm-commits] [llvm] r91250 - in /llvm/trunk: lib/ExecutionEngine/JIT/JIT.cpp unittests/ExecutionEngine/JIT/JITTest.cpp unittests/ExecutionEngine/JIT/Makefile
Jeffrey Yasskin
jyasskin at google.com
Sun Dec 13 12:30:33 PST 2009
Author: jyasskin
Date: Sun Dec 13 14:30:32 2009
New Revision: 91250
URL: http://llvm.org/viewvc/llvm-project?rev=91250&view=rev
Log:
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.
Modified:
llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp
llvm/trunk/unittests/ExecutionEngine/JIT/Makefile
Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=91250&r1=91249&r2=91250&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Sun Dec 13 14:30:32 2009
@@ -681,7 +681,7 @@
if (Ptr) return Ptr;
// If the global is external, just remember the address.
- if (GV->isDeclaration()) {
+ if (GV->isDeclaration() || GV->hasAvailableExternallyLinkage()) {
#if HAVE___DSO_HANDLE
if (GV->getName() == "__dso_handle")
return (void*)&__dso_handle;
Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=91250&r1=91249&r2=91250&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Sun Dec 13 14:30:32 2009
@@ -534,6 +534,31 @@
#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.
Modified: llvm/trunk/unittests/ExecutionEngine/JIT/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/Makefile?rev=91250&r1=91249&r2=91250&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/JIT/Makefile (original)
+++ llvm/trunk/unittests/ExecutionEngine/JIT/Makefile Sun Dec 13 14:30:32 2009
@@ -13,3 +13,6 @@
include $(LEVEL)/Makefile.config
include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
+
+# Permit these tests to use the JIT's symbolic lookup.
+LD.Flags += $(RDYNAMIC)
More information about the llvm-commits
mailing list