mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-08 02:30:48 +00:00
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
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user