diff options
author | Jeffrey Yasskin <jyasskin@google.com> | 2009-12-17 21:35:29 +0000 |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@google.com> | 2009-12-17 21:35:29 +0000 |
commit | 2b73a4e90f6b83fb5bece3f846321ebee1c89bf7 (patch) | |
tree | 5d8307036b6b783d2dcbf53bc60a3191adeb0bb3 /llvm/unittests/ExecutionEngine/JIT | |
parent | 7cc86b4cc63ccb0d3117255a3b9b724c7f86f40f (diff) | |
download | bcm5719-llvm-2b73a4e90f6b83fb5bece3f846321ebee1c89bf7.tar.gz bcm5719-llvm-2b73a4e90f6b83fb5bece3f846321ebee1c89bf7.zip |
Don't codegen available_externally functions. Fixes http://llvm.org/PR5735.
llvm-svn: 91626
Diffstat (limited to 'llvm/unittests/ExecutionEngine/JIT')
-rw-r--r-- | llvm/unittests/ExecutionEngine/JIT/JITTest.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp b/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp index bbf34603872..da4dfc4dda7 100644 --- a/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp +++ b/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp @@ -559,6 +559,35 @@ TEST_F(JITTest, AvailableExternallyGlobalIsntEmitted) { << " not 7 from the IR version."; } +} // anonymous namespace +// This function 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_AvailableExternallyFunction() { + return 42; +} +namespace { + +TEST_F(JITTest, AvailableExternallyFunctionIsntCompiled) { + TheJIT->DisableLazyCompilation(true); + LoadAssembly("define available_externally i32 " + " @JITTest_AvailableExternallyFunction() { " + " ret i32 7 " + "} " + " " + "define i32 @func() { " + " %result = tail call i32 " + " @JITTest_AvailableExternallyFunction() " + " ret i32 %result " + "} "); + Function *funcIR = M->getFunction("func"); + + int32_t (*func)() = reinterpret_cast<int32_t(*)()>( + (intptr_t)TheJIT->getPointerToFunction(funcIR)); + EXPECT_EQ(42, func()) << "func should return 42 from the static version," + << " 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. |