[llvm-commits] [llvm] r85366 - /llvm/trunk/lib/VMCore/Function.cpp
Chris Lattner
sabre at nondot.org
Tue Oct 27 20:37:35 PDT 2009
Author: lattner
Date: Tue Oct 27 22:37:35 2009
New Revision: 85366
URL: http://llvm.org/viewvc/llvm-project?rev=85366&view=rev
Log:
when we tear down a module, we need to be careful to
zap BlockAddress values.
Modified:
llvm/trunk/lib/VMCore/Function.cpp
Modified: llvm/trunk/lib/VMCore/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=85366&r1=85365&r2=85366&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Function.cpp (original)
+++ llvm/trunk/lib/VMCore/Function.cpp Tue Oct 27 22:37:35 2009
@@ -217,7 +217,20 @@
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) {
More information about the llvm-commits
mailing list