aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2009-10-09 22:10:27 +0000
committerJeffrey Yasskin <jyasskin@google.com>2009-10-09 22:10:27 +0000
commit307c053f2e0fd4d86993a2070e75ce7274af7f2f (patch)
tree5c5abff7f73ef2d2e1cc06461ffc2b90e479fe1b /llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
parentf4eb6777e55ae6b39f7b19d0c0e137311d97d799 (diff)
downloadllvm-307c053f2e0fd4d86993a2070e75ce7274af7f2f.zip
llvm-307c053f2e0fd4d86993a2070e75ce7274af7f2f.tar.gz
llvm-307c053f2e0fd4d86993a2070e75ce7274af7f2f.tar.bz2
ExecutionEngine::clearGlobalMappingsFromModule failed to remove reverse
mappings, which could cause errors and assert-failures. This patch fixes that, adds a test, and refactors the global-mapping-removal code into a single place. llvm-svn: 83678
Diffstat (limited to 'llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp')
-rw-r--r--llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp b/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
index 2106e86..97a8478 100644
--- a/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
+++ b/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
@@ -93,4 +93,24 @@ TEST_F(ExecutionEngineTest, ReverseGlobalMapping) {
<< " now-free address.";
}
+TEST_F(ExecutionEngineTest, ClearModuleMappings) {
+ GlobalVariable *G1 =
+ NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1");
+
+ int32_t Mem1 = 3;
+ Engine->addGlobalMapping(G1, &Mem1);
+ EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem1));
+
+ Engine->clearGlobalMappingsFromModule(M);
+
+ EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1));
+
+ GlobalVariable *G2 =
+ NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global2");
+ // After clearing the module mappings, we can assign a new GV to the
+ // same address.
+ Engine->addGlobalMapping(G2, &Mem1);
+ EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem1));
+}
+
}