summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2009-10-13 17:42:08 +0000
committerJeffrey Yasskin <jyasskin@google.com>2009-10-13 17:42:08 +0000
commitf98e981cd0340fc7b5b7ad39f506978a3fce2750 (patch)
tree131c64d8df5914d0396d0089948ac24ccb72c2b1 /llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
parent6bfee8f3e33627880eb5dfdb566c51f71a741f0d (diff)
downloadbcm5719-llvm-f98e981cd0340fc7b5b7ad39f506978a3fce2750.tar.gz
bcm5719-llvm-f98e981cd0340fc7b5b7ad39f506978a3fce2750.zip
Make the ExecutionEngine automatically remove global mappings on when their
GlobalValue is destroyed. Function destruction still leaks machine code and can crash on leaked stubs, but this is some progress. llvm-svn: 83987
Diffstat (limited to 'llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp')
-rw-r--r--llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp b/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
index 97a84783114..904ee2b6c49 100644
--- a/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
+++ b/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
@@ -113,4 +113,17 @@ TEST_F(ExecutionEngineTest, ClearModuleMappings) {
EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem1));
}
+TEST_F(ExecutionEngineTest, DestructionRemovesGlobalMapping) {
+ GlobalVariable *G1 =
+ NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1");
+ int32_t Mem1 = 3;
+ Engine->addGlobalMapping(G1, &Mem1);
+ // Make sure the reverse mapping is enabled.
+ EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem1));
+ // When the GV goes away, the ExecutionEngine should remove any
+ // mappings that refer to it.
+ G1->eraseFromParent();
+ EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1));
+}
+
}
OpenPOWER on IntegriCloud