@@ -5751,8 +5751,10 @@ struct AANonConvergent : public StateWrapper<BooleanState, AbstractAttribute> {
5751
5751
5752
5752
// / An abstract interface for struct information.
5753
5753
struct AAPointerInfo : public AbstractAttribute {
5754
+ protected:
5754
5755
AAPointerInfo (const IRPosition &IRP) : AbstractAttribute(IRP) {}
5755
5756
5757
+ public:
5756
5758
// / See AbstractAttribute::isValidIRPositionForInit
5757
5759
static bool isValidIRPositionForInit (Attributor &A, const IRPosition &IRP) {
5758
5760
if (!IRP.getAssociatedType ()->isPtrOrPtrVectorTy ())
@@ -6106,6 +6108,56 @@ struct AAPointerInfo : public AbstractAttribute {
6106
6108
Type *Ty;
6107
6109
};
6108
6110
6111
+ // / A helper containing a list of offsets computed for a Use. Ideally this
6112
+ // / list should be strictly ascending, but we ensure that only when we
6113
+ // / actually translate the list of offsets to a RangeList.
6114
+ struct OffsetInfo {
6115
+ using VecTy = SmallVector<int64_t >;
6116
+ using const_iterator = VecTy::const_iterator;
6117
+ VecTy Offsets;
6118
+
6119
+ const_iterator begin () const { return Offsets.begin (); }
6120
+ const_iterator end () const { return Offsets.end (); }
6121
+
6122
+ bool operator ==(const OffsetInfo &RHS) const {
6123
+ return Offsets == RHS.Offsets ;
6124
+ }
6125
+
6126
+ bool operator !=(const OffsetInfo &RHS) const { return !(*this == RHS); }
6127
+
6128
+ void insert (int64_t Offset) { Offsets.push_back (Offset); }
6129
+ bool isUnassigned () const { return Offsets.empty (); }
6130
+
6131
+ bool isUnknown () const {
6132
+ if (isUnassigned ())
6133
+ return false ;
6134
+ if (Offsets.size () == 1 )
6135
+ return Offsets.front () == AA::RangeTy::Unknown;
6136
+ return false ;
6137
+ }
6138
+
6139
+ void setUnknown () {
6140
+ Offsets.clear ();
6141
+ Offsets.push_back (AA::RangeTy::Unknown);
6142
+ }
6143
+
6144
+ void addToAll (int64_t Inc) {
6145
+ for (auto &Offset : Offsets)
6146
+ Offset += Inc;
6147
+ }
6148
+
6149
+ // / Copy offsets from \p R into the current list.
6150
+ // /
6151
+ // / Ideally all lists should be strictly ascending, but we defer that to the
6152
+ // / actual use of the list. So we just blindly append here.
6153
+ void merge (const OffsetInfo &R) {
6154
+ Offsets.append (R.Offsets );
6155
+ // ensure elements are unique.
6156
+ sort (Offsets.begin (), Offsets.end ());
6157
+ Offsets.erase (std::unique (Offsets.begin (), Offsets.end ()), Offsets.end ());
6158
+ }
6159
+ };
6160
+
6109
6161
// / Create an abstract attribute view for the position \p IRP.
6110
6162
static AAPointerInfo &createForPosition (const IRPosition &IRP, Attributor &A);
6111
6163
@@ -6120,6 +6172,9 @@ struct AAPointerInfo : public AbstractAttribute {
6120
6172
virtual const_bin_iterator begin () const = 0;
6121
6173
virtual const_bin_iterator end () const = 0;
6122
6174
virtual int64_t numOffsetBins () const = 0;
6175
+ virtual void dumpState (raw_ostream &O) const = 0;
6176
+ virtual const Access &getBinAccess (unsigned Index) const = 0;
6177
+ virtual const DenseMap<Value *, OffsetInfo> &getOffsetInfoMap () const = 0;
6123
6178
6124
6179
// / Call \p CB on all accesses that might interfere with \p Range and return
6125
6180
// / true if all such accesses were known and the callback returned true for
@@ -6291,6 +6346,9 @@ struct AAAllocationInfo : public StateWrapper<BooleanState, AbstractAttribute> {
6291
6346
6292
6347
virtual std::optional<TypeSize> getAllocatedSize () const = 0;
6293
6348
6349
+ using NewOffsetsTy = DenseMap<AA::RangeTy, AA::RangeTy>;
6350
+ virtual const NewOffsetsTy &getNewOffsets () const = 0;
6351
+
6294
6352
// / See AbstractAttribute::getName()
6295
6353
const std::string getName () const override { return " AAAllocationInfo" ; }
6296
6354
0 commit comments