File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments