[llvm] 4a08163 - [Attributor] Check HeapToStack's state for isKnownHeapToStack

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 4 09:38:43 PDT 2021


Author: Joseph Huber
Date: 2021-06-04T12:38:33-04:00
New Revision: 4a08163c73d403aa7fd5baeff693b1986b6c8df2

URL: https://github.com/llvm/llvm-project/commit/4a08163c73d403aa7fd5baeff693b1986b6c8df2
DIFF: https://github.com/llvm/llvm-project/commit/4a08163c73d403aa7fd5baeff693b1986b6c8df2.diff

LOG: [Attributor] Check HeapToStack's state for isKnownHeapToStack

This patch changes the `isKnownHeapToStack` and `isAssumedHeapToStack`
member functions to return if a function call is going to be altered by
HeapToStack.

Reviewed By: jdoerfert

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

Added: 
    

Modified: 
    llvm/include/llvm/Transforms/IPO/Attributor.h
    llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index bfe45a444012e..d02ec62fe1072 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -3223,10 +3223,10 @@ struct AAHeapToStack : public StateWrapper<BooleanState, AbstractAttribute> {
   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
index 534fd8ec38ba3..78ff7a65c0185 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -5019,6 +5019,16 @@ struct AAHeapToStackImpl : public AAHeapToStack {
     return "[H2S] Mallocs: " + std::to_string(MallocCalls.size());
   }
 
+  bool isAssumedHeapToStack(CallBase &CB) const override {
+    return isValidState() && MallocCalls.contains(&CB) &&
+           !BadMallocCalls.count(&CB);
+  }
+
+  bool isKnownHeapToStack(CallBase &CB) const override {
+    return isValidState() && MallocCalls.contains(&CB) &&
+           !BadMallocCalls.count(&CB);
+  }
+
   ChangeStatus manifest(Attributor &A) override {
     assert(getState().isValidState() &&
            "Attempted to manifest an invalid state!");


        


More information about the llvm-commits mailing list