summaryrefslogtreecommitdiff
path: root/unittests
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
commitc89d27a440370455336202b2a8f25eb9c73e67bc (patch)
tree351ff9e37997f9d3a55f8d5a16a1f07919217f99 /unittests
parent769b7f89534caed11d7595b5c84aa47d3de30ad9 (diff)
downloadllvm-c89d27a440370455336202b2a8f25eb9c73e67bc.tar.gz
llvm-c89d27a440370455336202b2a8f25eb9c73e67bc.tar.bz2
llvm-c89d27a440370455336202b2a8f25eb9c73e67bc.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83678 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ExecutionEngine/ExecutionEngineTest.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/unittests/ExecutionEngine/ExecutionEngineTest.cpp b/unittests/ExecutionEngine/ExecutionEngineTest.cpp
index 2106e86b59..97a8478311 100644
--- a/unittests/ExecutionEngine/ExecutionEngineTest.cpp
+++ b/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));
+}
+
}