[llvm] 603ae73 - AttributorAttributes: guard against TLI being nullptr

Augie Fackler via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 3 20:19:32 PDT 2022


Author: Augie Fackler
Date: 2022-04-03T23:19:23-04:00
New Revision: 603ae73146740f12986605b2a3e7b3817809bbb8

URL: https://github.com/llvm/llvm-project/commit/603ae73146740f12986605b2a3e7b3817809bbb8
DIFF: https://github.com/llvm/llvm-project/commit/603ae73146740f12986605b2a3e7b3817809bbb8.diff

LOG: AttributorAttributes: guard against TLI being nullptr

I didn't dig into this very much because it appears to be totally valid
(especially once these properties can come from attributes instead
of only from hard-coded library functions) for TLI to not be defined,
and nothing broke when I added this check, including with all my other
patches applied.

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

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 61eb0e43700d4..3342017ad4248 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -5899,7 +5899,8 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
         if (nullptr != getInitialValueOfAllocation(CB, TLI, I8Ty)) {
           AllocationInfo *AI = new (A.Allocator) AllocationInfo{CB};
           AllocationInfos[CB] = AI;
-          TLI->getLibFunc(*CB, AI->LibraryFunctionId);
+          if (TLI)
+            TLI->getLibFunc(*CB, AI->LibraryFunctionId);
         }
       }
       return true;


        


More information about the llvm-commits mailing list