auto BE = BB->end();
auto BBI = BasicBlock::iterator(LI);
BBI++;
- while (true) {
- for (; BBI != BE; BBI++) {
- auto* Inst = dyn_cast<Instruction>(&*BBI);
- if (Inst == nullptr) {
- continue;
- }
- if (Inst->getOpcode() == Instruction::Store) {
+ for (; BBI != BE; BBI++) {
+ auto* Inst = dyn_cast<Instruction>(&*BBI);
+ if (Inst == nullptr) {
+ continue;
+ }
+ if (Inst->getOpcode() == Instruction::Store) {
+ return Inst;
+ } else if (Inst->getOpcode() == Instruction::Br) {
+ auto* BrInst = dyn_cast<BranchInst>(Inst);
+ if (BrInst->isConditional()) {
return Inst;
- } else if (Inst->getOpcode() == Instruction::Br) {
- auto* BrInst = dyn_cast<BranchInst>(Inst);
- if (BrInst->isConditional()) {
- return Inst;
- } else {
- // Reinitialize iterators with the destination of the unconditional
- // branch.
- BB = BrInst->getSuccessor(0);
- BBI = BB->begin();
- BE = BB->end();
- break;
- }
+ } else {
+ return nullptr;
}
}
- if (BBI == BE) {
- return nullptr;
- }
}
+ return nullptr;
}
// XXX-comment: Returns whether the code has been changed.
if (StoreAddressDependOnValue(dyn_cast<StoreInst>(FirstInst), LI)) {
continue;
}
- } else if (FirstInst->getOpcode() == Instruction::Br) {
+ } else if (FirstInst->getOpcode() == Instruction::Br &&
+ isa<BranchInst>(FirstInst)) {
if (ConditionalBranchDependsOnValue(dyn_cast<BranchInst>(FirstInst),
LI)) {
continue;
}
const Use &U = I.getOperandUse(i);
+ if (!(InstsInThisBlock.count(Op) || DT.dominates(Op, U))) {
+ i = *((unsigned*) nullptr);
+ }
Assert(InstsInThisBlock.count(Op) || DT.dominates(Op, U),
"Instruction does not dominate all uses!", Op, &I);
}