forked from OSchip/llvm-project
[Attributor] Clamp operator to extend known state
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
This commit is contained in:
parent
39681e733c
commit
c395c9172f
|
@ -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);
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue