diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h --- a/llvm/include/llvm/Transforms/IPO/Attributor.h +++ b/llvm/include/llvm/Transforms/IPO/Attributor.h @@ -3538,6 +3538,7 @@ /// Returns true if HeapToStack conversion is assumed to be possible. virtual bool isAssumedHeapToStack(CallBase &CB) const = 0; + virtual bool isAssumedHeapToStack(const CallBase &CB) const = 0; /// Create an abstract attribute view for the position \p IRP. static AAHeapToStack &createForPosition(const IRPosition &IRP, Attributor &A); diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -5714,6 +5714,13 @@ return false; } + bool isAssumedHeapToStack(const CallBase &CB) const override { + if (isValidState()) + if (AllocationInfo *AI = AllocationInfos.lookup(&CB)) + return AI->Status != AllocationInfo::INVALID; + return false; + } + ChangeStatus manifest(Attributor &A) override { assert(getState().isValidState() && "Attempted to manifest an invalid state!");