Skip to content

Commit 2a5602f

Browse files
committed
!fixup use iterator to set last position to check.
1 parent a3350dd commit 2a5602f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -724,23 +724,24 @@ bool llvm::willNotFreeBetween(const Instruction *Assume,
724724
// Handle cross-block case: CtxI in a successor of Assume's block.
725725
const BasicBlock *CtxBB = CtxI->getParent();
726726
const BasicBlock *AssumeBB = Assume->getParent();
727+
BasicBlock::const_iterator CtxIter = CtxI->getIterator();
727728
if (CtxBB != AssumeBB) {
728729
if (CtxBB->getSinglePredecessor() != AssumeBB)
729730
return false;
730731

731732
if (!hasNoFreeCalls(make_range(CtxBB->begin(), CtxBB->end())))
732733
return false;
733734

734-
CtxI = AssumeBB->getTerminator();
735+
CtxIter = AssumeBB->end();
736+
} else {
737+
// Same block case: check that Assume comes before CtxI.
738+
if (!Assume->comesBefore(CtxI))
739+
return false;
735740
}
736741

737-
// Same block case: check that Assume comes before CtxI.
738-
if (!Assume->comesBefore(CtxI))
739-
return false;
740-
741-
// Check if there are any calls between Assume and CtxI that may free memory.
742-
return hasNoFreeCalls(
743-
make_range(Assume->getIterator(), std::next(CtxI->getIterator())));
742+
// Check if there are any calls between Assume and CtxIter that may free
743+
// memory.
744+
return hasNoFreeCalls(make_range(Assume->getIterator(), CtxIter));
744745
}
745746

746747
// TODO: cmpExcludesZero misses many cases where `RHS` is non-constant but

0 commit comments

Comments
 (0)