Skip to content

Commit

Permalink
[Attributor] Clamp operator to extend known state
Browse files Browse the repository at this point in the history
Summary:
Similar to `^=` operator for IntegerState, this patch introduces a `+=` operator to "clamp" known information.

Reviewers: jdoerfert, sstefan1

Reviewed By: jdoerfert

Subscribers: llvm-commits

Tags: #llvm

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

llvm-svn: 370015
  • Loading branch information
uenoku committed Aug 27, 2019
1 parent 39681e7 commit c395c91
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions llvm/include/llvm/Transforms/IPO/Attributor.h
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,13 @@ struct IntegerState : public AbstractState {
return *this;
}

/// "Clamp" this state with \p R. The result is the maximum of the known
/// information but not more than what was assumed before.
IntegerState operator+=(const IntegerState &R) {
takeKnownMaximum(R.Known);
return *this;
}

/// Make this the minimum, known and assumed, of this state and \p R.
IntegerState operator&=(const IntegerState &R) {
Known = std::min(Known, R.Known);
Expand Down Expand Up @@ -1445,6 +1452,13 @@ struct DerefState : AbstractState {
return *this;
}

/// See IntegerState::operator+=
DerefState operator+=(const DerefState &R) {
DerefBytesState += R.DerefBytesState;
GlobalState += R.GlobalState;
return *this;
}

/// See IntegerState::operator&=
DerefState operator&=(const DerefState &R) {
DerefBytesState &= R.DerefBytesState;
Expand Down

0 comments on commit c395c91

Please sign in to comment.