// should remove End to ensure that work done at the other exits does not
// happen outside of the lifetime.
template <typename F>
-bool forAllReachableExits(DominatorTree *DT, PostDominatorTree *PDT,
+bool forAllReachableExits(const DominatorTree &DT, const PostDominatorTree &PDT,
const Instruction *Start, Instruction *End,
const SmallVectorImpl<Instruction *> &RetVec,
F Callback) {
// We need to ensure that if we tag some object, we certainly untag it
// before the function exits.
- if (PDT != nullptr && PDT->dominates(End, Start)) {
+ if (PDT.dominates(End, Start)) {
Callback(End);
} else {
SmallVector<Instruction *, 8> ReachableRetVec;
unsigned NumCoveredExits = 0;
for (auto &RI : RetVec) {
- if (!isPotentiallyReachable(Start, RI, nullptr, DT))
+ if (!isPotentiallyReachable(Start, RI, nullptr, &DT))
continue;
ReachableRetVec.push_back(RI);
- if (DT != nullptr && DT->dominates(End, RI))
+ if (DT.dominates(End, RI))
++NumCoveredExits;
}
// If there's a mix of covered and non-covered exits, just put the untag
tagAlloca(AI, Start->getNextNode(), Start->getArgOperand(1), Size);
auto TagEnd = [&](Instruction *Node) { untagAlloca(AI, Node, Size); };
- if (!forAllReachableExits(DT, PDT, Start, End, RetVec, TagEnd))
+ if (!DT || !PDT ||
+ !forAllReachableExits(*DT, *PDT, Start, End, RetVec, TagEnd))
End->eraseFromParent();
} else {
uint64_t Size = Info.AI->getAllocationSizeInBits(*DL).getValue() / 8;