diff options
author | Devang Patel <dpatel@apple.com> | 2009-02-04 21:39:48 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-02-04 21:39:48 +0000 |
commit | d0a203d76f4ef77ae1c392e8e73e2f05b676a5f2 (patch) | |
tree | c14f9a82177ae146c40333a1ab42f2e389a646b3 /lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 4781ad62d19f3cbc687b4480f283be754c0bad17 (diff) |
Ignore dbg intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63781 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 25070aa42d..ba00f6127e 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/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())) |