forked from OSchip/llvm-project
[NFC] Add parameter for keeping one-input Phis in DeleteDeadBlock(s)
llvm-svn: 353799
This commit is contained in:
parent
7670ede434
commit
0686d1ae41
|
@ -41,19 +41,25 @@ class Value;
|
|||
|
||||
/// Replace contents of every block in \p BBs with single unreachable
|
||||
/// instruction. If \p Updates is specified, collect all necessary DT updates
|
||||
/// into this vector.
|
||||
/// into this vector. If \p DontDeleteUselessPHIs is true, one-input Phis in
|
||||
/// successors of blocks being deleted will be preserved.
|
||||
void DetatchDeadBlocks(ArrayRef <BasicBlock *> BBs,
|
||||
SmallVectorImpl<DominatorTree::UpdateType> *Updates);
|
||||
SmallVectorImpl<DominatorTree::UpdateType> *Updates,
|
||||
bool DontDeleteUselessPHIs = false);
|
||||
|
||||
/// Delete the specified block, which must have no predecessors.
|
||||
void DeleteDeadBlock(BasicBlock *BB, DomTreeUpdater *DTU = nullptr);
|
||||
void DeleteDeadBlock(BasicBlock *BB, DomTreeUpdater *DTU = nullptr,
|
||||
bool DontDeleteUselessPHIs = false);
|
||||
|
||||
/// Delete the specified blocks from \p BB. The set of deleted blocks must have
|
||||
/// no predecessors that are not being deleted themselves. \p BBs must have no
|
||||
/// duplicating blocks. If there are loops among this set of blocks, all
|
||||
/// relevant loop info updates should be done before this function is called.
|
||||
/// If \p DontDeleteUselessPHIs is true, one-input Phis in successors of blocks
|
||||
/// being deleted will be preserved.
|
||||
void DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs,
|
||||
DomTreeUpdater *DTU = nullptr);
|
||||
DomTreeUpdater *DTU = nullptr,
|
||||
bool DontDeleteUselessPHIs = false);
|
||||
|
||||
/// We know that BB has one predecessor. If there are any single-entry PHI nodes
|
||||
/// in it, fold them away. This handles the case when all entries to the PHI
|
||||
|
|
|
@ -49,13 +49,14 @@ using namespace llvm;
|
|||
|
||||
void llvm::DetatchDeadBlocks(
|
||||
ArrayRef<BasicBlock *> BBs,
|
||||
SmallVectorImpl<DominatorTree::UpdateType> *Updates) {
|
||||
SmallVectorImpl<DominatorTree::UpdateType> *Updates,
|
||||
bool DontDeleteUselessPHIs) {
|
||||
for (auto *BB : BBs) {
|
||||
// Loop through all of our successors and make sure they know that one
|
||||
// of their predecessors is going away.
|
||||
SmallPtrSet<BasicBlock *, 4> UniqueSuccessors;
|
||||
for (BasicBlock *Succ : successors(BB)) {
|
||||
Succ->removePredecessor(BB);
|
||||
Succ->removePredecessor(BB, DontDeleteUselessPHIs);
|
||||
if (Updates && UniqueSuccessors.insert(Succ).second)
|
||||
Updates->push_back({DominatorTree::Delete, BB, Succ});
|
||||
}
|
||||
|
@ -80,12 +81,13 @@ void llvm::DetatchDeadBlocks(
|
|||
}
|
||||
}
|
||||
|
||||
void llvm::DeleteDeadBlock(BasicBlock *BB, DomTreeUpdater *DTU) {
|
||||
DeleteDeadBlocks({BB}, DTU);
|
||||
void llvm::DeleteDeadBlock(BasicBlock *BB, DomTreeUpdater *DTU,
|
||||
bool DontDeleteUselessPHIs) {
|
||||
DeleteDeadBlocks({BB}, DTU, DontDeleteUselessPHIs);
|
||||
}
|
||||
|
||||
void llvm::DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs,
|
||||
DomTreeUpdater *DTU) {
|
||||
void llvm::DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs, DomTreeUpdater *DTU,
|
||||
bool DontDeleteUselessPHIs) {
|
||||
#ifndef NDEBUG
|
||||
// Make sure that all predecessors of each dead block is also dead.
|
||||
SmallPtrSet<BasicBlock *, 4> Dead(BBs.begin(), BBs.end());
|
||||
|
@ -96,7 +98,7 @@ void llvm::DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs,
|
|||
#endif
|
||||
|
||||
SmallVector<DominatorTree::UpdateType, 4> Updates;
|
||||
DetatchDeadBlocks(BBs, DTU ? &Updates : nullptr);
|
||||
DetatchDeadBlocks(BBs, DTU ? &Updates : nullptr, DontDeleteUselessPHIs);
|
||||
|
||||
if (DTU)
|
||||
DTU->applyUpdates(Updates, /*ForceRemoveDuplicates*/ true);
|
||||
|
|
Loading…
Reference in New Issue