[Attributor][NFC] AAReachability is currently stateless, don't invalidate it
authorJohannes Doerfert <johannes@jdoerfert.de>
Thu, 6 May 2021 21:42:01 +0000 (16:42 -0500)
committerJohannes Doerfert <johannes@jdoerfert.de>
Fri, 18 Jun 2021 06:07:51 +0000 (01:07 -0500)
We invalidated AAReachabilityImpl directly which is not helpful and
confusing as we still used it regardless. We now avoid invalidating it
(not needed anyway) and add checks for the state. This has by itself no
actual effect but prepares for later extensions.

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

index 439c0a4..4a0c921 100644 (file)
@@ -2704,6 +2704,8 @@ struct AAReachability : public StateWrapper<BooleanState, AbstractAttribute> {
   /// determines (and caches) reachability.
   bool isAssumedReachable(Attributor &A, const Instruction &From,
                           const Instruction &To) const {
+    if (!getState().isValidState())
+      return true;
     return A.getInfoCache().getPotentiallyReachable(From, To);
   }
 
@@ -2712,6 +2714,8 @@ struct AAReachability : public StateWrapper<BooleanState, AbstractAttribute> {
   /// determines (and caches) reachability.
   bool isKnownReachable(Attributor &A, const Instruction &From,
                         const Instruction &To) const {
+    if (!getState().isValidState())
+      return false;
     return A.getInfoCache().getPotentiallyReachable(From, To);
   }
 
index 9fbbb98..9832b2d 100644 (file)
@@ -2388,12 +2388,9 @@ struct AAReachabilityImpl : AAReachability {
     return "reachable";
   }
 
-  /// See AbstractAttribute::initialize(...).
-  void initialize(Attributor &A) override { indicatePessimisticFixpoint(); }
-
   /// See AbstractAttribute::updateImpl(...).
   ChangeStatus updateImpl(Attributor &A) override {
-    return indicatePessimisticFixpoint();
+    return ChangeStatus::UNCHANGED;
   }
 };