[MCJIT] Make repeat calls to MCJIT::getPointerToFunction for declarations safe.
[oota-llvm.git] / unittests / ExecutionEngine / MCJIT / MCJITTest.cpp
index 15e0efdb9710a43c40f03d6de3f681979491ac29..64d8c2fca042aedcc26478d8ccc0fe52a69d1aa5 100644 (file)
@@ -187,4 +187,16 @@ TEST_F(MCJITTest, multiple_functions) {
 
 #endif /*!defined(__arm__)*/
 
+TEST_F(MCJITTest, multiple_decl_lookups) {
+  SKIP_UNSUPPORTED_PLATFORM;
+
+  Function *Foo = insertExternalReferenceToFunction<void(void)>(M.get(), "_exit");
+  createJIT(std::move(M));
+  void *A = TheJIT->getPointerToFunction(Foo);
+  void *B = TheJIT->getPointerToFunction(Foo);
+
+  EXPECT_TRUE(A != 0) << "Failed lookup - test not correctly configured.";
+  EXPECT_EQ(A, B) << "Repeat calls to getPointerToFunction fail.";
+}
+
 }