[llvm] 49f2b41 - [Attributor] Gracefully handle interprocedural reachability queries

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 19 22:35:56 PDT 2021


Author: Johannes Doerfert
Date: 2021-07-20T00:35:14-05:00
New Revision: 49f2b41e6f9d5bea4d6803cc27bf667dd2bf4b63

URL: https://github.com/llvm/llvm-project/commit/49f2b41e6f9d5bea4d6803cc27bf667dd2bf4b63
DIFF: https://github.com/llvm/llvm-project/commit/49f2b41e6f9d5bea4d6803cc27bf667dd2bf4b63.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/include/llvm/Transforms/IPO/Attributor.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 50e46d72680b..9f5007a21188 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -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));


        


More information about the llvm-commits mailing list