summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-02-24 17:30:48 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-02-24 17:30:48 +0000
commitee0cbbbe69e51373265c293adc1a02608a8b1d7a (patch)
treee31eb90e54ae575feb00fd92b8e6bb260503806d /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parentcd25a2bef02ffe03aa1e16d361eb4f871371b870 (diff)
downloadbcm5719-llvm-ee0cbbbe69e51373265c293adc1a02608a8b1d7a.tar.gz
bcm5719-llvm-ee0cbbbe69e51373265c293adc1a02608a8b1d7a.zip
[SimplifyCFG] Use a more elegant solution than r261731
The cleanupret instruction has an invariant that it's 'from' operand be a cleanuppad. This invariant was violated when we removed a dead block which removed a cleanuppad leaving behind a cleanupret with an undef 'from' operand. This was solved in r261731 by staving off the removal of the dead block to a later pass. However, it occured to me that we do not need to do this. Instead, we can simply avoid processing the cleanupret if it has an undef 'from' operand because we know that it will be removed soon. llvm-svn: 261754
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 7a3d368f34c..3e689f6ad9a 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3521,6 +3521,12 @@ static bool mergeCleanupPad(CleanupReturnInst *RI) {
}
bool SimplifyCFGOpt::SimplifyCleanupReturn(CleanupReturnInst *RI) {
+ // It is possible to transiantly have an undef cleanuppad operand because we
+ // have deleted some, but not all, dead blocks.
+ // Eventually, this block will be deleted.
+ if (isa<UndefValue>(RI->getOperand(0)))
+ return false;
+
if (removeEmptyCleanup(RI))
return true;
@@ -5278,17 +5284,9 @@ bool SimplifyCFGOpt::run(BasicBlock *BB) {
if ((pred_empty(BB) &&
BB != &BB->getParent()->getEntryBlock()) ||
BB->getSinglePredecessor() == BB) {
- // Get the block mostly empty.
- Changed |= removeAllNonTerminatorAndEHPadInstructions(BB) > 0;
- // Now, verify that we succeeded getting the block empty.
- // This will not be the case if this unreachable BB creates a token which is
- // consumed by other unreachable blocks.
- Instruction *FirstNonPHI = BB->getFirstNonPHI();
- if (isa<TerminatorInst>(FirstNonPHI) && FirstNonPHI->use_empty()) {
- DEBUG(dbgs() << "Removing BB: \n" << *BB);
- DeleteDeadBlock(BB);
- return true;
- }
+ DEBUG(dbgs() << "Removing BB: \n" << *BB);
+ DeleteDeadBlock(BB);
+ return true;
}
// Check to see if we can constant propagate this terminator instruction
OpenPOWER on IntegriCloud