Skip to content

Commit

Permalink
[BasicAA] Don't assume DT is nonnull
Browse files Browse the repository at this point in the history
I thought DT is required in BasicAA, but apparently it can be null
in unit tests at least. This should fix the ubsan bot failures.
  • Loading branch information
nikic committed Nov 21, 2023
1 parent ff75121 commit 7f740be
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions llvm/lib/Analysis/BasicAliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ bool SimpleCaptureInfo::isNotCapturedBefore(const Value *Object,
return isNonEscapingLocalObject(Object, &IsCapturedCache);
}

static bool isNotInCycle(const Instruction *I, const DominatorTree &DT,
static bool isNotInCycle(const Instruction *I, const DominatorTree *DT,
const LoopInfo *LI) {
BasicBlock *BB = const_cast<BasicBlock *>(I->getParent());
SmallVector<BasicBlock *> Succs(successors(BB));
return Succs.empty() ||
!isPotentiallyReachableFromMany(Succs, BB, nullptr, &DT, LI);
!isPotentiallyReachableFromMany(Succs, BB, nullptr, DT, LI);
}

bool EarliestEscapeInfo::isNotCapturedBefore(const Value *Object,
Expand All @@ -231,7 +231,7 @@ bool EarliestEscapeInfo::isNotCapturedBefore(const Value *Object,
if (I == Iter.first->second) {
if (OrAt)
return false;
return isNotInCycle(I, DT, LI);
return isNotInCycle(I, &DT, LI);
}

return !isPotentiallyReachable(Iter.first->second, I, nullptr, &DT, LI);
Expand Down Expand Up @@ -1721,7 +1721,7 @@ bool BasicAAResult::isValueEqualInPotentialCycles(const Value *V,
if (!Inst || Inst->getParent()->isEntryBlock())
return true;

return isNotInCycle(Inst, *DT, /*LI*/ nullptr);
return isNotInCycle(Inst, DT, /*LI*/ nullptr);
}

/// Computes the symbolic difference between two de-composed GEPs.
Expand Down

0 comments on commit 7f740be

Please sign in to comment.