[llvm] 5163779 - [Attributor] Port AANoFree to the isImpliedByIR interface

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 9 16:05:01 PDT 2023


Author: Johannes Doerfert
Date: 2023-07-09T16:04:20-07:00
New Revision: 5163779232cd786b2da44b6aa2afb26770a65a0a

URL: https://github.com/llvm/llvm-project/commit/5163779232cd786b2da44b6aa2afb26770a65a0a
DIFF: https://github.com/llvm/llvm-project/commit/5163779232cd786b2da44b6aa2afb26770a65a0a.diff

LOG: [Attributor] Port AANoFree to the isImpliedByIR interface

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 00611695b6f3e7..a9cefc75451dee 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -3254,6 +3254,8 @@ void Attributor::identifyDefaultAbstractAttributes(Function &F) {
   IRPosition FPos = IRPosition::function(F);
   bool IsIPOAmendable = isFunctionIPOAmendable(F);
   auto Attrs = F.getAttributes();
+  auto FnAttrs = Attrs.getFnAttrs();
+
   // Check for dead BasicBlocks in every function.
   // We need dead instruction detection because we do not want to deal with
   // broken IR in which SSA rules do not apply.
@@ -3289,8 +3291,7 @@ void Attributor::identifyDefaultAbstractAttributes(Function &F) {
       getOrCreateAAFor<AANoSync>(FPos);
 
     // Every function might be "no-free".
-    if (!Attrs.hasFnAttr(Attribute::NoFree))
-      getOrCreateAAFor<AANoFree>(FPos);
+    checkAndQueryIRAttr<Attribute::NoFree, AANoFree>(FPos, FnAttrs);
 
     // Every function might be "no-return".
     if (!Attrs.hasFnAttr(Attribute::NoReturn))
@@ -3393,8 +3394,7 @@ void Attributor::identifyDefaultAbstractAttributes(Function &F) {
         getOrCreateAAFor<AAMemoryBehavior>(ArgPos);
 
         // Every argument with pointer type might be marked nofree.
-        if (!Attrs.hasParamAttr(ArgNo, Attribute::NoFree))
-          getOrCreateAAFor<AANoFree>(ArgPos);
+        checkAndQueryIRAttr<Attribute::NoFree, AANoFree>(ArgPos, ArgAttrs);
 
         // Every argument with pointer type might be privatizable (or
         // promotable)
@@ -3489,8 +3489,7 @@ void Attributor::identifyDefaultAbstractAttributes(Function &F) {
         getOrCreateAAFor<AAMemoryBehavior>(CBArgPos);
 
       // Call site argument attribute "nofree".
-      if (!CBAttrs.hasParamAttr(I, Attribute::NoFree))
-        getOrCreateAAFor<AANoFree>(CBArgPos);
+      checkAndQueryIRAttr<Attribute::NoFree, AANoFree>(CBArgPos, CBArgAttrs);
     }
     return true;
   };

diff  --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 223d30b71c392d..d981ed5c1110bc 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -2483,6 +2483,13 @@ namespace {
 struct AANoFreeImpl : public AANoFree {
   AANoFreeImpl(const IRPosition &IRP, Attributor &A) : AANoFree(IRP, A) {}
 
+  /// See AbstractAttribute::initialize(...).
+  void initialize(Attributor &A) override {
+    bool IsKnown;
+    assert(!AA::hasAssumedIRAttr<Attribute::NoFree>(A, nullptr, getIRPosition(),
+                                                    DepClassTy::NONE, IsKnown));
+  }
+
   /// See AbstractAttribute::updateImpl(...).
   ChangeStatus updateImpl(Attributor &A) override {
     auto CheckForNoFree = [&](Instruction &I) {


        


More information about the llvm-commits mailing list