[llvm] 12173e6 - [Attributor][NFC] Do not record dependences on fixed attributes

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 30 18:46:37 PDT 2019


Author: Johannes Doerfert
Date: 2019-10-30T20:44:03-05:00
New Revision: 12173e60ec430214f4035edd12720f86fe2c9588

URL: https://github.com/llvm/llvm-project/commit/12173e60ec430214f4035edd12720f86fe2c9588
DIFF: https://github.com/llvm/llvm-project/commit/12173e60ec430214f4035edd12720f86fe2c9588.diff

LOG: [Attributor][NFC] Do not record dependences on fixed attributes

Since fixed values cannot change, we do not need to wait for it to
happen, we will never notify the dependent attribute anyway.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 90d88ce21e9a..43c1811059a3 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -733,9 +733,7 @@ struct Attributor {
   /// be beneficial to avoid false dependences but it requires the users of
   /// `getAAFor` to explicitly record true dependences through this method.
   void recordDependence(const AbstractAttribute &FromAA,
-                        const AbstractAttribute &ToAA) {
-    QueryMap[&FromAA].insert(const_cast<AbstractAttribute *>(&ToAA));
-  }
+                        const AbstractAttribute &ToAA);
 
   /// Introduce a new abstract attribute into the fixpoint analysis.
   ///
@@ -907,7 +905,7 @@ struct Attributor {
     AA.update(*this);
 
     if (TrackDependence && AA.getState().isValidState())
-      QueryMap[&AA].insert(const_cast<AbstractAttribute *>(QueryingAA));
+      recordDependence(AA, const_cast<AbstractAttribute &>(*QueryingAA));
     return AA;
   }
 
@@ -929,7 +927,7 @@ struct Attributor {
             KindToAbstractAttributeMap.lookup(&AAType::ID))) {
       // Do not register a dependence on an attribute with an invalid state.
       if (TrackDependence && AA->getState().isValidState())
-        QueryMap[AA].insert(const_cast<AbstractAttribute *>(QueryingAA));
+        recordDependence(*AA, const_cast<AbstractAttribute &>(*QueryingAA));
       return AA;
     }
     return nullptr;

diff  --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index b397f5a16558..a18be0c78497 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -4711,6 +4711,12 @@ void Attributor::initializeInformationCache(Function &F) {
   }
 }
 
+void Attributor::recordDependence(const AbstractAttribute &FromAA,
+                                  const AbstractAttribute &ToAA) {
+  if (!FromAA.getState().isAtFixpoint())
+    QueryMap[&FromAA].insert(const_cast<AbstractAttribute *>(&ToAA));
+}
+
 void Attributor::identifyDefaultAbstractAttributes(Function &F) {
   if (!VisitedFunctions.insert(&F).second)
     return;


        


More information about the llvm-commits mailing list