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 @@ -3222,10 +3222,10 @@ AAHeapToStack(const IRPosition &IRP, Attributor &A) : Base(IRP) {} /// Returns true if HeapToStack conversion is assumed to be possible. - bool isAssumedHeapToStack() const { return getAssumed(); } + virtual bool isAssumedHeapToStack(CallBase &CB) const = 0; /// Returns true if HeapToStack conversion is known to be possible. - bool isKnownHeapToStack() const { return getKnown(); } + virtual bool isKnownHeapToStack(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 @@ -5019,6 +5019,14 @@ return "[H2S] Mallocs: " + std::to_string(MallocCalls.size()); } + bool isAssumedHeapToStack(CallBase &CB) const override { + return MallocCalls.contains(&CB) && !BadMallocCalls.count(&CB); + } + + bool isKnownHeapToStack(CallBase &CB) const override { + return MallocCalls.contains(&CB) && !BadMallocCalls.count(&CB); + } + ChangeStatus manifest(Attributor &A) override { assert(getState().isValidState() && "Attempted to manifest an invalid state!");