summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ADT/StringRefTest.cpp6
-rw-r--r--unittests/ADT/ValueMapTest.cpp3
-rw-r--r--unittests/ExecutionEngine/JIT/JITTest.cpp40
3 files changed, 41 insertions, 8 deletions
diff --git a/unittests/ADT/StringRefTest.cpp b/unittests/ADT/StringRefTest.cpp
index 11545d539b289..dfa208abefdc2 100644
--- a/unittests/ADT/StringRefTest.cpp
+++ b/unittests/ADT/StringRefTest.cpp
@@ -111,11 +111,6 @@ TEST(StringRefTest, Split) {
Str.rsplit('o'));
}
-// XFAIL for PR5482, StringRef is miscompiled by Apple gcc.
-#if (!defined(__llvm__) && defined(__APPLE__) && defined(__OPTIMIZE__))
-#define SKIP_SPLIT2
-#endif
-#ifndef SKIP_SPLIT2
TEST(StringRefTest, Split2) {
SmallVector<StringRef, 5> parts;
SmallVector<StringRef, 5> expected;
@@ -195,7 +190,6 @@ TEST(StringRefTest, Split2) {
StringRef("a,,b,c").split(parts, ",", 3, false);
EXPECT_TRUE(parts == expected);
}
-#endif
TEST(StringRefTest, StartsWith) {
StringRef Str("hello");
diff --git a/unittests/ADT/ValueMapTest.cpp b/unittests/ADT/ValueMapTest.cpp
index 915965753045e..451e30a7434b7 100644
--- a/unittests/ADT/ValueMapTest.cpp
+++ b/unittests/ADT/ValueMapTest.cpp
@@ -11,6 +11,7 @@
#include "llvm/Instructions.h"
#include "llvm/LLVMContext.h"
#include "llvm/ADT/OwningPtr.h"
+#include "llvm/Config/config.h"
#include "gtest/gtest.h"
@@ -193,6 +194,7 @@ struct LockMutex : ValueMapConfig<KeyT> {
}
static sys::Mutex *getMutex(const ExtraData &Data) { return Data.M; }
};
+#if ENABLE_THREADS
TYPED_TEST(ValueMapTest, LocksMutex) {
sys::Mutex M(false); // Not recursive.
bool CalledRAUW = false, CalledDeleted = false;
@@ -205,6 +207,7 @@ TYPED_TEST(ValueMapTest, LocksMutex) {
EXPECT_TRUE(CalledRAUW);
EXPECT_TRUE(CalledDeleted);
}
+#endif
template<typename KeyT>
struct NoFollow : ValueMapConfig<KeyT> {
diff --git a/unittests/ExecutionEngine/JIT/JITTest.cpp b/unittests/ExecutionEngine/JIT/JITTest.cpp
index 98b292244fecc..12c6b67d98754 100644
--- a/unittests/ExecutionEngine/JIT/JITTest.cpp
+++ b/unittests/ExecutionEngine/JIT/JITTest.cpp
@@ -183,6 +183,7 @@ class JITTest : public testing::Test {
M = new Module("<main>", Context);
MP = new ExistingModuleProvider(M);
RJMM = new RecordingJITMemoryManager;
+ RJMM->setPoisonMemory(true);
std::string Error;
TheJIT.reset(EngineBuilder(MP).setEngineKind(EngineKind::JIT)
.setJITMemoryManager(RJMM)
@@ -311,7 +312,6 @@ TEST_F(JITTest, FarCallToKnownFunction) {
EXPECT_EQ(8, TestFunctionPtr());
}
-#if !defined(__arm__) && !defined(__powerpc__) && !defined(__ppc__)
// Test a function C which calls A and B which call each other.
TEST_F(JITTest, NonLazyCompilationStillNeedsStubs) {
TheJIT->DisableLazyCompilation(true);
@@ -407,7 +407,6 @@ TEST_F(JITTest, NonLazyLeaksNoStubs) {
EXPECT_EQ(Func2->getNumUses(), 0u);
Func2->eraseFromParent();
}
-#endif
TEST_F(JITTest, ModuleDeletion) {
TheJIT->DisableLazyCompilation(false);
@@ -458,6 +457,9 @@ TEST_F(JITTest, ModuleDeletion) {
NumTablesDeallocated);
}
+// ARM and PPC still emit stubs for calls since the target may be too far away
+// to call directly. This #if can probably be removed when
+// http://llvm.org/PR5201 is fixed.
#if !defined(__arm__) && !defined(__powerpc__) && !defined(__ppc__)
typedef int (*FooPtr) ();
@@ -496,7 +498,41 @@ TEST_F(JITTest, NoStubs) {
ASSERT_EQ(stubsBefore, RJMM->stubsAllocated);
}
+#endif // !ARM && !PPC
+
+TEST_F(JITTest, FunctionPointersOutliveTheirCreator) {
+ TheJIT->DisableLazyCompilation(true);
+ LoadAssembly("define i8()* @get_foo_addr() { "
+ " ret i8()* @foo "
+ "} "
+ " "
+ "define i8 @foo() { "
+ " ret i8 42 "
+ "} ");
+ Function *F_get_foo_addr = M->getFunction("get_foo_addr");
+
+ typedef char(*fooT)();
+ fooT (*get_foo_addr)() = reinterpret_cast<fooT(*)()>(
+ (intptr_t)TheJIT->getPointerToFunction(F_get_foo_addr));
+ fooT foo_addr = get_foo_addr();
+
+ // Now free get_foo_addr. This should not free the machine code for foo or
+ // any call stub returned as foo's canonical address.
+ TheJIT->freeMachineCodeForFunction(F_get_foo_addr);
+
+ // Check by calling the reported address of foo.
+ EXPECT_EQ(42, foo_addr());
+
+ // The reported address should also be the same as the result of a subsequent
+ // getPointerToFunction(foo).
+#if 0
+ // Fails until PR5126 is fixed:
+ Function *F_foo = M->getFunction("foo");
+ fooT foo = reinterpret_cast<fooT>(
+ (intptr_t)TheJIT->getPointerToFunction(F_foo));
+ EXPECT_EQ((intptr_t)foo, (intptr_t)foo_addr);
#endif
+}
// 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