summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-02-04 21:39:48 +0000
committerDevang Patel <dpatel@apple.com>2009-02-04 21:39:48 +0000
commit916fdce16de000115576f09462df91a1ad65bc6f (patch)
tree834ec1b2908e2c653f06c7c0e19e68212182260b /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parentfb5fdf1f149ecfbc3258ab4af495abbd20e39645 (diff)
downloadbcm5719-llvm-916fdce16de000115576f09462df91a1ad65bc6f.tar.gz
bcm5719-llvm-916fdce16de000115576f09462df91a1ad65bc6f.zip
Ignore dbg intrinsics.
llvm-svn: 63781
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp36
1 files changed, 29 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 25070aa42d6..ba00f6127ef 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1430,14 +1430,24 @@ static bool FoldBranchToCommonDest(BranchInst *BI) {
// Only allow this if the condition is a simple instruction that can be
// executed unconditionally. It must be in the same block as the branch, and
// must be at the front of the block.
+ BasicBlock::iterator FrontIt = BB->front();
+ // Ignore dbg intrinsics.
+ while(isa<DbgInfoIntrinsic>(FrontIt))
+ ++FrontIt;
if ((!isa<CmpInst>(Cond) && !isa<BinaryOperator>(Cond)) ||
- Cond->getParent() != BB || &BB->front() != Cond || !Cond->hasOneUse())
+ Cond->getParent() != BB || &*FrontIt != Cond || !Cond->hasOneUse()) {
return false;
+ }
// Make sure the instruction after the condition is the cond branch.
BasicBlock::iterator CondIt = Cond; ++CondIt;
- if (&*CondIt != BI)
+ // Ingore dbg intrinsics.
+ while(isa<DbgInfoIntrinsic>(CondIt))
+ ++CondIt;
+ if (&*CondIt != BI) {
+ assert (!isa<DbgInfoIntrinsic>(CondIt) && "Hey do not forget debug info!");
return false;
+ }
// Cond is known to be a compare or binary operator. Check to make sure that
// neither operand is a potentially-trapping constant expression.
@@ -1867,6 +1877,9 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
BasicBlock::iterator BBI = BB->getFirstNonPHI();
BasicBlock *Succ = BI->getSuccessor(0);
+ // Ignore dbg intrinsics.
+ while (isa<DbgInfoIntrinsic>(BBI))
+ ++BBI;
if (BBI->isTerminator() && // Terminator is the only non-phi instruction!
Succ != BB) // Don't hurt infinite loops!
if (TryToSimplifyUncondBranchFromEmptyBlock(BB, Succ))
@@ -1884,15 +1897,24 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
// This block must be empty, except for the setcond inst, if it exists.
// Ignore dbg intrinsics.
BasicBlock::iterator I = BB->begin();
+ // Ignore dbg intrinsics.
while (isa<DbgInfoIntrinsic>(I))
- I++;
- if (&*I == BI ||
- (&*I == cast<Instruction>(BI->getCondition()) &&
- &*++I == BI))
+ ++I;
+ if (&*I == BI) {
if (FoldValueComparisonIntoPredecessors(BI))
return SimplifyCFG(BB) | true;
+ } else if (&*I == cast<Instruction>(BI->getCondition())){
+ ++I;
+ // Ignore dbg intrinsics.
+ while (isa<DbgInfoIntrinsic>(I))
+ ++I;
+ if(&*I == BI) {
+ if (FoldValueComparisonIntoPredecessors(BI))
+ return SimplifyCFG(BB) | true;
+ }
+ }
}
-
+
// If this is a branch on a phi node in the current block, thread control
// through this block if any PHI node entries are constants.
if (PHINode *PN = dyn_cast<PHINode>(BI->getCondition()))
OpenPOWER on IntegriCloud