[PATCH] D30381: [SCCP] Remove manual folding of terminator instructions.
Xin Tong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 25 18:23:12 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296281: [SCCP] Remove manual folding of terminator instructions. (authored by trentxintong).
Changed prior to commit:
https://reviews.llvm.org/D30381?vs=89802&id=89805#toc
Repository:
rL LLVM
https://reviews.llvm.org/D30381
Files:
llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
Index: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
@@ -1824,32 +1824,9 @@
if (!I) continue;
bool Folded = ConstantFoldTerminator(I->getParent());
- if (!Folded) {
- // The constant folder may not have been able to fold the terminator
- // if this is a branch or switch on undef. Fold it manually as a
- // branch to the first successor.
-#ifndef NDEBUG
- if (auto *BI = dyn_cast<BranchInst>(I)) {
- assert(BI->isConditional() && isa<UndefValue>(BI->getCondition()) &&
- "Branch should be foldable!");
- } else if (auto *SI = dyn_cast<SwitchInst>(I)) {
- assert(isa<UndefValue>(SI->getCondition()) && "Switch should fold");
- } else {
- llvm_unreachable("Didn't fold away reference to block!");
- }
-#endif
-
- // Make this an uncond branch to the first successor.
- TerminatorInst *TI = I->getParent()->getTerminator();
- BranchInst::Create(TI->getSuccessor(0), TI);
-
- // Remove entries in successor phi nodes to remove edges.
- for (unsigned i = 1, e = TI->getNumSuccessors(); i != e; ++i)
- TI->getSuccessor(i)->removePredecessor(TI->getParent());
-
- // Remove the old terminator.
- TI->eraseFromParent();
- }
+ assert(Folded &&
+ "Expect TermInst on constantint or blockaddress to be folded");
+ (void) Folded;
}
// Finally, delete the basic block.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30381.89805.patch
Type: text/x-patch
Size: 1679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170226/bc25ced8/attachment.bin>
More information about the llvm-commits
mailing list