Skip to content

Commit ff1002a

Browse files
[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
1 parent 92e82a2 commit ff1002a

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3359,12 +3359,32 @@ struct AAValueConstantRange
33593359
/// force it. As for the conditions under which we force it, see
33603360
/// AAPotentialValues.
33613361
template <typename MemberTy, typename KeyInfo = DenseMapInfo<MemberTy>>
3362-
struct PotentialValuesState : BooleanState {
3362+
struct PotentialValuesState : AbstractState {
33633363
using SetTy = DenseSet<MemberTy, KeyInfo>;
33643364

3365-
PotentialValuesState() : BooleanState(true) {}
3365+
PotentialValuesState() : IsValidState(true) {}
33663366

3367-
PotentialValuesState(bool IsValid) : BooleanState(IsValid) {}
3367+
PotentialValuesState(bool IsValid) : IsValidState(IsValid) {}
3368+
3369+
/// See AbstractState::isValidState(...)
3370+
bool isValidState() const { return IsValidState.isValidState(); }
3371+
3372+
/// See AbstractState::isAtFixpoint(...)
3373+
bool isAtFixpoint() const { return IsValidState.isAtFixpoint(); }
3374+
3375+
/// See AbstractState::indicatePessimisticFixpoint(...)
3376+
ChangeStatus indicatePessimisticFixpoint() {
3377+
return IsValidState.indicatePessimisticFixpoint();
3378+
}
3379+
3380+
/// See AbstractState::indicateOptimisticFixpoint(...)
3381+
ChangeStatus indicateOptimisticFixpoint() {
3382+
return IsValidState.indicateOptimisticFixpoint();
3383+
}
3384+
3385+
/// Return the assumed state
3386+
PotentialValuesState &getAssumed() { return *this; }
3387+
const PotentialValuesState &getAssumed() const { return *this; }
33683388

33693389
/// Return this set. We should check whether this set is valid or not by
33703390
/// isValidState() before calling this function.
@@ -3465,6 +3485,9 @@ struct PotentialValuesState : BooleanState {
34653485
Set = IntersectSet;
34663486
}
34673487

3488+
/// A helper state which indicate whether this state is valid or not.
3489+
BooleanState IsValidState;
3490+
34683491
/// Container for potential values
34693492
SetTy Set;
34703493
};

0 commit comments

Comments
 (0)