AttributorAttributes: guard against TLI being nullptr
authorAugie Fackler <augie@google.com>
Thu, 31 Mar 2022 18:46:51 +0000 (14:46 -0400)
committerAugie Fackler <augie@google.com>
Mon, 4 Apr 2022 03:19:23 +0000 (23:19 -0400)
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

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

index 61eb0e4..3342017 100644 (file)
@@ -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;