[Attributor] Gracefully handle interprocedural reachability queries

This does ensure `InformationCache::getPotentiallyReachable` will not
crash/assert on instructions from different functions but simply return
that one is reachable, which is conservatively correct.
This commit is contained in:
Johannes Doerfert 2021-07-20 00:30:20 -05:00
parent b96ea6b1fd
commit 49f2b41e6f
1 changed files with 3 additions and 1 deletions

View File

@ -996,7 +996,9 @@ struct InformationCache {
if (Iter != PotentiallyReachableMap.end())
return Iter->second;
const Function &F = *From.getFunction();
bool Result = isPotentiallyReachable(
bool Result = true;
if (From.getFunction() == To.getFunction())
Result = isPotentiallyReachable(
&From, &To, nullptr, AG.getAnalysis<DominatorTreeAnalysis>(F),
AG.getAnalysis<LoopAnalysis>(F));
PotentiallyReachableMap.insert(std::make_pair(KeyPair, Result));