[PATCH] D85610: [Attributor][AAPotentialValues] Change interface of PotentialValuesState

Shinji Okumura via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 9 08:28:18 PDT 2020


okura created this revision.
Herald added a reviewer: uenoku.
Herald added subscribers: llvm-commits, kuter, uenoku.
Herald added a reviewer: homerdin.
Herald added a project: LLVM.
okura requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a reviewer: baziotis.
Herald added a subscriber: bbn.

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.


https://reviews.llvm.org/D85610

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


Index: llvm/include/llvm/Transforms/IPO/Attributor.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/Attributor.h
+++ llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -3359,12 +3359,32 @@
 /// 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 @@
     Set = IntersectSet;
   }
 
+  /// A helper state which indicate whether this state is valid or not.
+  BooleanState IsValidState;
+
   /// Container for potential values
   SetTy Set;
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85610.284209.patch
Type: text/x-patch
Size: 1851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200809/704a332b/attachment.bin>


More information about the llvm-commits mailing list