From f10e287c65894d2bac0b19a99f8e9f0856a00eb0 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Wed, 4 Feb 2009 00:03:08 +0000 Subject: Ignore dbg intrinsics while hoisting common code in the two blocks up into the branch block. llvm-svn: 63687 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp') diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 9f5df98fc0f..ea68abe22d9 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -853,7 +853,14 @@ static bool HoistThenElseCodeToIf(BranchInst *BI) { BasicBlock *BB1 = BI->getSuccessor(0); // The true destination. BasicBlock *BB2 = BI->getSuccessor(1); // The false destination - Instruction *I1 = BB1->begin(), *I2 = BB2->begin(); + BasicBlock::iterator BB1_Itr = BB1->begin(); + BasicBlock::iterator BB2_Itr = BB2->begin(); + + Instruction *I1 = BB1_Itr++, *I2 = BB2_Itr++; + while (isa(I1)) + I1 = BB1_Itr++; + while (isa(I2)) + I2 = BB2_Itr++; if (I1->getOpcode() != I2->getOpcode() || isa(I1) || isa(I1) || !I1->isIdenticalTo(I2)) return false; @@ -875,8 +882,12 @@ static bool HoistThenElseCodeToIf(BranchInst *BI) { I2->replaceAllUsesWith(I1); BB2->getInstList().erase(I2); - I1 = BB1->begin(); - I2 = BB2->begin(); + I1 = BB1_Itr++; + while (isa(I1)) + I1 = BB1_Itr++; + I2 = BB2_Itr++; + while (isa(I2)) + I2 = BB2_Itr++; } while (I1->getOpcode() == I2->getOpcode() && I1->isIdenticalTo(I2)); return true; -- cgit v1.2.3