From 36bf506ad3c99a309ca8bd73bd03563d8d068ac0 Mon Sep 17 00:00:00 2001 From: Roman Divacky Date: Wed, 4 Nov 2009 14:58:56 +0000 Subject: Update LLVM to r86025. --- lib/VMCore/Function.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lib/VMCore/Function.cpp') diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 8ad885c4c23d1..6cf2c8186f9be 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(BB->use_back()); + BA->replaceAllUsesWith(UndefValue::get(BA->getType())); + BA->destroyConstant(); + } + + BB->eraseFromParent(); + } } void Function::addAttribute(unsigned i, Attributes attr) { -- cgit v1.2.3