diff options
author | Jeffrey Yasskin <jyasskin@google.com> | 2009-12-12 05:58:14 +0000 |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@google.com> | 2009-12-12 05:58:14 +0000 |
commit | 2d2dcdcbf7df12f7fb277aca81df45c83f39c43e (patch) | |
tree | 1fa52b10ee5cfd0813f061a59ea59cb7729d7ac4 /llvm/unittests/ExecutionEngine/JIT | |
parent | 1615d45daaf1fb40a8a6acb0bddf29b2daae322f (diff) | |
download | bcm5719-llvm-2d2dcdcbf7df12f7fb277aca81df45c83f39c43e.tar.gz bcm5719-llvm-2d2dcdcbf7df12f7fb277aca81df45c83f39c43e.zip |
Fix available_externally linkage for globals. It's probably still not
supported by emitGlobals, but I don't have a test case for that.
llvm-svn: 91208
Diffstat (limited to 'llvm/unittests/ExecutionEngine/JIT')
-rw-r--r-- | llvm/unittests/ExecutionEngine/JIT/JITTest.cpp | 25 |
1 files changed, 25 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. |