aboutsummaryrefslogtreecommitdiffstats
path: root/unittests/ExecutionEngine
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
commit2be240354e170f362ec70ba0aa68e1f070d71f9c (patch)
tree196d4fab533df6a761c49ff32e66c1379aa74913 /unittests/ExecutionEngine
parent0bcdc3f719e79dcd849918aa1ee1712801cd8078 (diff)
downloadexternal_llvm-2be240354e170f362ec70ba0aa68e1f070d71f9c.zip
external_llvm-2be240354e170f362ec70ba0aa68e1f070d71f9c.tar.gz
external_llvm-2be240354e170f362ec70ba0aa68e1f070d71f9c.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83987 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ExecutionEngine')
-rw-r--r--unittests/ExecutionEngine/ExecutionEngineTest.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/unittests/ExecutionEngine/ExecutionEngineTest.cpp b/unittests/ExecutionEngine/ExecutionEngineTest.cpp
index 97a8478..904ee2b 100644
--- a/unittests/ExecutionEngine/ExecutionEngineTest.cpp
+++ b/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));
+}
+
}