[llvm] ff1002a - [Attributor][NFC][AAPotentialValues] Change interface of PotentialValuesState

Shinji Okumura via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 9 17:27:41 PDT 2020


Author: Shinji Okumura
Date: 2020-08-10T09:18:10+09:00
New Revision: ff1002aab0911c585a9850fe7315b1e604c271f9

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

LOG: [Attributor][NFC][AAPotentialValues] Change interface of PotentialValuesState

Previously `PotentialValuesState` inherited `BooleanState`.
We have to add `getAssumed` to the state in order to use `clampStateAndIndicateChange` (which will be used in `AAPotentialValuesArgument`).
However `BooleanState::getAssumed` is not a virtual function and we cannot override it.
Therefore, I changed the state not to inherit `BooleanState` and add `getAssumed` to it.

Reviewed By: jdoerfert

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index b15c8f0dd6c3..a6df1a993e04 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -3359,12 +3359,32 @@ struct AAValueConstantRange
 /// force it. As for the conditions under which we force it, see
 /// AAPotentialValues.
 template <typename MemberTy, typename KeyInfo = DenseMapInfo<MemberTy>>
-struct PotentialValuesState : BooleanState {
+struct PotentialValuesState : AbstractState {
   using SetTy = DenseSet<MemberTy, KeyInfo>;
 
-  PotentialValuesState() : BooleanState(true) {}
+  PotentialValuesState() : IsValidState(true) {}
 
-  PotentialValuesState(bool IsValid) : BooleanState(IsValid) {}
+  PotentialValuesState(bool IsValid) : IsValidState(IsValid) {}
+
+  /// See AbstractState::isValidState(...)
+  bool isValidState() const { return IsValidState.isValidState(); }
+
+  /// See AbstractState::isAtFixpoint(...)
+  bool isAtFixpoint() const { return IsValidState.isAtFixpoint(); }
+
+  /// See AbstractState::indicatePessimisticFixpoint(...)
+  ChangeStatus indicatePessimisticFixpoint() {
+    return IsValidState.indicatePessimisticFixpoint();
+  }
+
+  /// See AbstractState::indicateOptimisticFixpoint(...)
+  ChangeStatus indicateOptimisticFixpoint() {
+    return IsValidState.indicateOptimisticFixpoint();
+  }
+
+  /// Return the assumed state
+  PotentialValuesState &getAssumed() { return *this; }
+  const PotentialValuesState &getAssumed() const { return *this; }
 
   /// Return this set. We should check whether this set is valid or not by
   /// isValidState() before calling this function.
@@ -3465,6 +3485,9 @@ struct PotentialValuesState : BooleanState {
     Set = IntersectSet;
   }
 
+  /// A helper state which indicate whether this state is valid or not.
+  BooleanState IsValidState;
+
   /// Container for potential values
   SetTy Set;
 };


        


More information about the llvm-commits mailing list