File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -103,12 +103,14 @@ class ConstantIntRanges {
103
103
// / value.
104
104
std::optional<APInt> getConstantValue () const ;
105
105
106
- // / Returns true if signed range is poisoned, i.e. no valid signed value
107
- // / can be represented.
106
+ // / Returns true if signed range is poisoned, poisoned ranges are propagated
107
+ // / through the DAG and will cause the immediate UB if reached the
108
+ // / side-effecting operation.
108
109
bool isSignedPoison () const ;
109
110
110
- // / Returns true if unsigned range is poisoned, i.e. no valid unsigned value
111
- // / can be represented.
111
+ // / Returns true if unsigned range is poisoned, poisoned ranges are propagated
112
+ // / through the DAG and will cause the immediate UB if reached the
113
+ // / side-effecting operation.
112
114
bool isUnsignedPoison () const ;
113
115
114
116
friend raw_ostream &operator <<(raw_ostream &os,
Original file line number Diff line number Diff line change @@ -112,6 +112,13 @@ ConstantIntRanges::rangeUnion(const ConstantIntRanges &other) const {
112
112
APInt sminUnion;
113
113
APInt smaxUnion;
114
114
115
+ // Union of poisoned range with any other range is the other range.
116
+ // Union is used when we need to merge ranges from multiple indepdenent
117
+ // sources, e.g. in `arith.select` or CFG merge. "Observing" a poisoned
118
+ // value (using it in side-effecting operation) will cause the immediate UB.
119
+ // Well-formed programs should never observe the immediate UB so we assume
120
+ // result is either unused or only used in circumstances when it received the
121
+ // non-poisoned argument.
115
122
if (isUnsignedPoison ()) {
116
123
uminUnion = other.umin ();
117
124
umaxUnion = other.umax ();
@@ -151,6 +158,7 @@ ConstantIntRanges::intersection(const ConstantIntRanges &other) const {
151
158
APInt sminIntersect;
152
159
APInt smaxIntersect;
153
160
161
+ // Intersection of poisoned range with any other range is poisoned.
154
162
if (isUnsignedPoison ()) {
155
163
uminIntersect = umin ();
156
164
umaxIntersect = umax ();
You can’t perform that action at this time.
0 commit comments