diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-28 03:37:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-28 03:37:35 +0000 |
commit | 1e0dc8e12396ee8021c91c6115585f5877f35efb (patch) | |
tree | e4c6a1bf6362f5ada2728d8971578b618fe80de8 /lib/VMCore/Function.cpp | |
parent | 6d013fc381db73b4e9d413e786b95db9b2fefd57 (diff) | |
download | external_llvm-1e0dc8e12396ee8021c91c6115585f5877f35efb.zip external_llvm-1e0dc8e12396ee8021c91c6115585f5877f35efb.tar.gz external_llvm-1e0dc8e12396ee8021c91c6115585f5877f35efb.tar.bz2 |
when we tear down a module, we need to be careful to
zap BlockAddress values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85366 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Function.cpp')
-rw-r--r-- | lib/VMCore/Function.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 8ad885c..6cf2c81 100644 --- a/lib/VMCore/Function.cpp +++ b/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) { |