diff options
| author | Johannes Doerfert <jdoerfert@anl.gov> | 2019-08-27 04:57:54 +0000 | 
|---|---|---|
| committer | Johannes Doerfert <jdoerfert@anl.gov> | 2019-08-27 04:57:54 +0000 | 
| commit | 39681e733cd0887b4531dd0d17c17e3245a9b242 (patch) | |
| tree | f305db7c7bbd6dbadf11d90323009c3900e35521 /llvm/lib/Transforms | |
| parent | 20650eda995b65c9626a524a635e3fff8e4d1b93 (diff) | |
| download | bcm5719-llvm-39681e733cd0887b4531dd0d17c17e3245a9b242.tar.gz bcm5719-llvm-39681e733cd0887b4531dd0d17c17e3245a9b242.zip | |
[Attributor] Introduce an API to delete stuff
Summary:
During the fixpoint iteration, including the manifest stage, we should
not delete stuff as other abstract attributes might have a reference to
the value. Through the API this can now be done safely at the very end.
Reviewers: uenoku, sstefan1
Subscribers: hiraditya, bollu, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66779
llvm-svn: 370014
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/IPO/Attributor.cpp | 20 | 
1 files changed, 20 insertions, 0 deletions
| diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index a6e8e528fd0..a2d470affc0 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -2641,6 +2641,26 @@ ChangeStatus Attributor::run() {    assert(        NumFinalAAs == AllAbstractAttributes.size() &&        "Expected the final number of abstract attributes to remain unchanged!"); + +  // Delete stuff at the end to avoid invalid references and a nice order. +  LLVM_DEBUG(dbgs() << "\n[Attributor] Delete " << ToBeDeletedFunctions.size() +                    << " functions and " << ToBeDeletedBlocks.size() +                    << " blocks and " << ToBeDeletedInsts.size() +                    << " instructions\n"); +  for (Instruction *I : ToBeDeletedInsts) { +    if (I->hasNUsesOrMore(1)) +      I->replaceAllUsesWith(UndefValue::get(I->getType())); +    I->eraseFromParent(); +  } +  for (BasicBlock *BB : ToBeDeletedBlocks) { +    // TODO: Check if we need to replace users (PHIs, indirect branches?) +    BB->eraseFromParent(); +  } +  for (Function *Fn : ToBeDeletedFunctions) { +    Fn->replaceAllUsesWith(UndefValue::get(Fn->getType())); +    Fn->eraseFromParent(); +  } +    return ManifestChange;  } | 

