mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
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
This commit is contained in:
parent
6d013fc381
commit
1e0dc8e123
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user