diff options
author | Jeffrey Yasskin <jyasskin@google.com> | 2009-10-09 22:10:27 +0000 |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@google.com> | 2009-10-09 22:10:27 +0000 |
commit | c89d27a440370455336202b2a8f25eb9c73e67bc (patch) | |
tree | 351ff9e37997f9d3a55f8d5a16a1f07919217f99 /unittests | |
parent | 769b7f89534caed11d7595b5c84aa47d3de30ad9 (diff) | |
download | external_llvm-c89d27a440370455336202b2a8f25eb9c73e67bc.zip external_llvm-c89d27a440370455336202b2a8f25eb9c73e67bc.tar.gz external_llvm-c89d27a440370455336202b2a8f25eb9c73e67bc.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.
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.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/unittests/ExecutionEngine/ExecutionEngineTest.cpp b/unittests/ExecutionEngine/ExecutionEngineTest.cpp index 2106e86..97a8478 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)); +} + } |