@@ -1146,24 +1146,27 @@ struct IntegerStateBase : public AbstractState {
1146
1146
};
1147
1147
1148
1148
// / Specialization of the integer state for a bit-wise encoding.
1149
- struct BitIntegerState : public IntegerStateBase <uint32_t , ~0u , 0 > {
1150
- using base_t = IntegerStateBase::base_t ;
1149
+ template <typename base_ty = uint32_t , base_ty BestState = ~base_ty (0 ),
1150
+ base_ty WorstState = 0 >
1151
+ struct BitIntegerState
1152
+ : public IntegerStateBase<base_ty, BestState, WorstState> {
1153
+ using base_t = base_ty;
1151
1154
1152
1155
// / Return true if the bits set in \p BitsEncoding are "known bits".
1153
1156
bool isKnown (base_t BitsEncoding) const {
1154
- return (Known & BitsEncoding) == BitsEncoding;
1157
+ return (this -> Known & BitsEncoding) == BitsEncoding;
1155
1158
}
1156
1159
1157
1160
// / Return true if the bits set in \p BitsEncoding are "assumed bits".
1158
1161
bool isAssumed (base_t BitsEncoding) const {
1159
- return (Assumed & BitsEncoding) == BitsEncoding;
1162
+ return (this -> Assumed & BitsEncoding) == BitsEncoding;
1160
1163
}
1161
1164
1162
1165
// / Add the bits in \p BitsEncoding to the "known bits".
1163
1166
BitIntegerState &addKnownBits (base_t Bits) {
1164
1167
// Make sure we never miss any "known bits".
1165
- Assumed |= Bits;
1166
- Known |= Bits;
1168
+ this -> Assumed |= Bits;
1169
+ this -> Known |= Bits;
1167
1170
return *this ;
1168
1171
}
1169
1172
@@ -1174,14 +1177,14 @@ struct BitIntegerState : public IntegerStateBase<uint32_t, ~0u, 0> {
1174
1177
1175
1178
// / Remove the bits in \p BitsEncoding from the "known bits".
1176
1179
BitIntegerState &removeKnownBits (base_t BitsEncoding) {
1177
- Known = (Known & ~BitsEncoding);
1180
+ this -> Known = (this -> Known & ~BitsEncoding);
1178
1181
return *this ;
1179
1182
}
1180
1183
1181
1184
// / Keep only "assumed bits" also set in \p BitsEncoding but all known ones.
1182
1185
BitIntegerState &intersectAssumedBits (base_t BitsEncoding) {
1183
1186
// Make sure we never loose any "known bits".
1184
- Assumed = (Assumed & BitsEncoding) | Known;
1187
+ this -> Assumed = (this -> Assumed & BitsEncoding) | this -> Known ;
1185
1188
return *this ;
1186
1189
}
1187
1190
@@ -1191,32 +1194,35 @@ struct BitIntegerState : public IntegerStateBase<uint32_t, ~0u, 0> {
1191
1194
}
1192
1195
void handleNewKnownValue (base_t Value) override { addKnownBits (Value); }
1193
1196
void joinOR (base_t AssumedValue, base_t KnownValue) override {
1194
- Known |= KnownValue;
1195
- Assumed |= AssumedValue;
1197
+ this -> Known |= KnownValue;
1198
+ this -> Assumed |= AssumedValue;
1196
1199
}
1197
1200
void joinAND (base_t AssumedValue, base_t KnownValue) override {
1198
- Known &= KnownValue;
1199
- Assumed &= AssumedValue;
1201
+ this -> Known &= KnownValue;
1202
+ this -> Assumed &= AssumedValue;
1200
1203
}
1201
1204
};
1202
1205
1203
1206
// / Specialization of the integer state for an increasing value, hence ~0u is
1204
1207
// / the best state and 0 the worst.
1205
- struct IncIntegerState : public IntegerStateBase <uint32_t , ~0u , 0 > {
1206
- using base_t = IntegerStateBase::base_t ;
1208
+ template <typename base_ty = uint32_t , base_ty BestState = ~base_ty (0 ),
1209
+ base_ty WorstState = 0 >
1210
+ struct IncIntegerState
1211
+ : public IntegerStateBase<base_ty, BestState, WorstState> {
1212
+ using base_t = base_ty;
1207
1213
1208
1214
// / Take minimum of assumed and \p Value.
1209
1215
IncIntegerState &takeAssumedMinimum (base_t Value) {
1210
1216
// Make sure we never loose "known value".
1211
- Assumed = std::max (std::min (Assumed, Value), Known);
1217
+ this -> Assumed = std::max (std::min (this -> Assumed , Value), this -> Known );
1212
1218
return *this ;
1213
1219
}
1214
1220
1215
1221
// / Take maximum of known and \p Value.
1216
1222
IncIntegerState &takeKnownMaximum (base_t Value) {
1217
1223
// Make sure we never loose "known value".
1218
- Assumed = std::max (Value, Assumed);
1219
- Known = std::max (Value, Known);
1224
+ this -> Assumed = std::max (Value, this -> Assumed );
1225
+ this -> Known = std::max (Value, this -> Known );
1220
1226
return *this ;
1221
1227
}
1222
1228
@@ -1226,12 +1232,12 @@ struct IncIntegerState : public IntegerStateBase<uint32_t, ~0u, 0> {
1226
1232
}
1227
1233
void handleNewKnownValue (base_t Value) override { takeKnownMaximum (Value); }
1228
1234
void joinOR (base_t AssumedValue, base_t KnownValue) override {
1229
- Known = std::max (Known, KnownValue);
1230
- Assumed = std::max (Assumed, AssumedValue);
1235
+ this -> Known = std::max (this -> Known , KnownValue);
1236
+ this -> Assumed = std::max (this -> Assumed , AssumedValue);
1231
1237
}
1232
1238
void joinAND (base_t AssumedValue, base_t KnownValue) override {
1233
- Known = std::min (Known, KnownValue);
1234
- Assumed = std::min (Assumed, AssumedValue);
1239
+ this -> Known = std::min (this -> Known , KnownValue);
1240
+ this -> Assumed = std::min (this -> Assumed , AssumedValue);
1235
1241
}
1236
1242
};
1237
1243
@@ -1752,7 +1758,7 @@ struct AAIsDead : public StateWrapper<BooleanState, AbstractAttribute>,
1752
1758
struct DerefState : AbstractState {
1753
1759
1754
1760
// / State representing for dereferenceable bytes.
1755
- IncIntegerState DerefBytesState;
1761
+ IncIntegerState<> DerefBytesState;
1756
1762
1757
1763
// / State representing that whether the value is globaly dereferenceable.
1758
1764
BooleanState GlobalState;
@@ -1866,10 +1872,12 @@ struct AADereferenceable
1866
1872
static const char ID;
1867
1873
};
1868
1874
1875
+ using AAAlignmentStateType =
1876
+ IncIntegerState<uint32_t , /* maximal alignment */ 1U << 29 , 0 >;
1869
1877
// / An abstract interface for all align attributes.
1870
- struct AAAlign
1871
- : public IRAttribute< Attribute::Alignment,
1872
- StateWrapper<IncIntegerState , AbstractAttribute>> {
1878
+ struct AAAlign : public IRAttribute <
1879
+ Attribute::Alignment,
1880
+ StateWrapper<AAAlignmentStateType , AbstractAttribute>> {
1873
1881
AAAlign (const IRPosition &IRP) : IRAttribute(IRP) {}
1874
1882
1875
1883
// / Return assumed alignment.
@@ -1887,8 +1895,9 @@ struct AAAlign
1887
1895
1888
1896
// / An abstract interface for all nocapture attributes.
1889
1897
struct AANoCapture
1890
- : public IRAttribute<Attribute::NoCapture,
1891
- StateWrapper<BitIntegerState, AbstractAttribute>> {
1898
+ : public IRAttribute<
1899
+ Attribute::NoCapture,
1900
+ StateWrapper<BitIntegerState<uint16_t , 7 , 0 >, AbstractAttribute>> {
1892
1901
AANoCapture (const IRPosition &IRP) : IRAttribute(IRP) {}
1893
1902
1894
1903
// / State encoding bits. A set bit in the state means the property holds.
@@ -1978,8 +1987,9 @@ struct AAHeapToStack : public StateWrapper<BooleanState, AbstractAttribute>,
1978
1987
1979
1988
// / An abstract interface for all memory related attributes.
1980
1989
struct AAMemoryBehavior
1981
- : public IRAttribute<Attribute::ReadNone,
1982
- StateWrapper<BitIntegerState, AbstractAttribute>> {
1990
+ : public IRAttribute<
1991
+ Attribute::ReadNone,
1992
+ StateWrapper<BitIntegerState<uint8_t , 3 >, AbstractAttribute>> {
1983
1993
AAMemoryBehavior (const IRPosition &IRP) : IRAttribute(IRP) {}
1984
1994
1985
1995
// / State encoding bits. A set bit in the state means the property holds.
0 commit comments