summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2009-12-17 21:35:29 +0000
committerJeffrey Yasskin <jyasskin@google.com>2009-12-17 21:35:29 +0000
commitaad0d52c5bc088e6182f83becee29846bb00d592 (patch)
tree6273108e8c1c00d194fdec33e486ac847522d02a /unittests
parent8e4b197e0b9b382b717074510cecc205be7f1eb4 (diff)
downloadllvm-aad0d52c5bc088e6182f83becee29846bb00d592.tar.gz
llvm-aad0d52c5bc088e6182f83becee29846bb00d592.tar.bz2
llvm-aad0d52c5bc088e6182f83becee29846bb00d592.tar.xz
Don't codegen available_externally functions. Fixes http://llvm.org/PR5735.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91626 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ExecutionEngine/JIT/JITTest.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/unittests/ExecutionEngine/JIT/JITTest.cpp b/unittests/ExecutionEngine/JIT/JITTest.cpp
index bbf3460387..da4dfc4dda 100644
--- a/unittests/ExecutionEngine/JIT/JITTest.cpp
+++ b/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.