summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Function.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-28 03:37:35 +0000
committerChris Lattner <sabre@nondot.org>2009-10-28 03:37:35 +0000
commit3a395304458bb882d4c7234e016cfb8ce1918e6b (patch)
tree226cbd2ff8ebb31bf9a5ecf3a1d020d965f5f45d /llvm/lib/VMCore/Function.cpp
parent1c4b03c2d7f18eccb7aedfa8920a0460d506b1e6 (diff)
downloadbcm5719-llvm-3a395304458bb882d4c7234e016cfb8ce1918e6b.tar.gz
bcm5719-llvm-3a395304458bb882d4c7234e016cfb8ce1918e6b.zip
when we tear down a module, we need to be careful to
zap BlockAddress values. llvm-svn: 85366
Diffstat (limited to 'llvm/lib/VMCore/Function.cpp')
-rw-r--r--llvm/lib/VMCore/Function.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp
index 8ad885c4c23..6cf2c8186f9 100644
--- a/llvm/lib/VMCore/Function.cpp
+++ b/llvm/lib/VMCore/Function.cpp
@@ -217,7 +217,20 @@ void Function::setParent(Module *parent) {
void Function::dropAllReferences() {
for (iterator I = begin(), E = end(); I != E; ++I)
I->dropAllReferences();
- BasicBlocks.clear(); // Delete all basic blocks...
+
+ // Delete all basic blocks.
+ while (!BasicBlocks.empty()) {
+ // If there is still a reference to the block, it must be a 'blockaddress'
+ // constant pointing to it. Just replace the BlockAddress with undef.
+ BasicBlock *BB = BasicBlocks.begin();
+ if (!BB->use_empty()) {
+ BlockAddress *BA = cast<BlockAddress>(BB->use_back());
+ BA->replaceAllUsesWith(UndefValue::get(BA->getType()));
+ BA->destroyConstant();
+ }
+
+ BB->eraseFromParent();
+ }
}
void Function::addAttribute(unsigned i, Attributes attr) {
OpenPOWER on IntegriCloud