// Branch - See if we are conditional jumping on constant
if (BranchInst *BI = dyn_cast<BranchInst>(T)) {
if (BI->isUnconditional()) return false; // Can't optimize uncond branch
- BasicBlock *Dest1 = cast<BasicBlock>(BI->getOperand(0));
- BasicBlock *Dest2 = cast<BasicBlock>(BI->getOperand(1));
+ BasicBlock *Dest1 = BI->getSuccessor(0);
+ BasicBlock *Dest2 = BI->getSuccessor(1);
if (ConstantInt *Cond = dyn_cast<ConstantInt>(BI->getCondition())) {
// Are we branching on constant?
// Nuke BB.
PredBB->eraseFromParent();
}
+
+/// OnlyUsedByDbgIntrinsics - Return true if the instruction I is only used
+/// by DbgIntrinsics. If DbgInUses is specified then the vector is filled
+/// with the DbgInfoIntrinsic that use the instruction I.
+bool llvm::OnlyUsedByDbgInfoIntrinsics(Instruction *I,
+ SmallVectorImpl<DbgInfoIntrinsic *> *DbgInUses) {
+ if (DbgInUses)
+ DbgInUses->clear();
+
+ for (Value::use_iterator UI = I->use_begin(), UE = I->use_end(); UI != UE;
+ ++UI) {
+ if (DbgInfoIntrinsic *DI = dyn_cast<DbgInfoIntrinsic>(*UI)) {
+ if (DbgInUses)
+ DbgInUses->push_back(DI);
+ } else {
+ if (DbgInUses)
+ DbgInUses->clear();
+ return false;
+ }
+ }
+ return true;
+}