[llvm] 9029bda - [Attributor] Don't crash if getAnalysisResultForFunction() returns null LoopInfo

Augie Fackler via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 12 13:44:20 PDT 2022


Author: Augie Fackler
Date: 2022-07-12T16:44:06-04:00
New Revision: 9029bda0419fc710aecd03328b67457e59dcd80e

URL: https://github.com/llvm/llvm-project/commit/9029bda0419fc710aecd03328b67457e59dcd80e
DIFF: https://github.com/llvm/llvm-project/commit/9029bda0419fc710aecd03328b67457e59dcd80e.diff

LOG: [Attributor] Don't crash if getAnalysisResultForFunction() returns null LoopInfo

I have no idea what's going on here. This code was moved
around/introduced in change cb26b01d57f5 and starts crashing with a NULL
dereference once I apply https://reviews.llvm.org/D123090. I assume that
I've unwittingly taught the attributor enough that it's able to do more
clever things than in the past, and it's able to trip on this case. I
make no claims about the correctness of this patch, but it passes tests
and seems to fix all the crashes I've been seeing.

Differential Revision: https://reviews.llvm.org/D129589

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index c00a045fe8469..d1d488fbe61fd 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -6402,6 +6402,8 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
       MayContainIrreducibleControl = mayContainIrreducibleControl(*F, LI);
     if (MayContainIrreducibleControl.value())
       return true;
+    if (!LI)
+      return true;
     return LI->getLoopFor(&BB) != nullptr;
   };
 


        


More information about the llvm-commits mailing list