From c89d27a440370455336202b2a8f25eb9c73e67bc Mon Sep 17 00:00:00 2001 From: Jeffrey Yasskin Date: Fri, 9 Oct 2009 22:10:27 +0000 Subject: 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 --- unittests/ExecutionEngine/ExecutionEngineTest.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'unittests') 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)); +} + } -- cgit v1.2.3