[llvm] [Attributor]: AApointerInfo - store the full chain of instructions that make up the access (PR #96526)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 8 08:18:41 PDT 2024
================
@@ -5785,6 +5793,136 @@ struct AAPointerInfo : public AbstractAttribute {
AK_MUST_READ_WRITE = AK_MUST | AK_R | AK_W,
};
+ /// A helper containing a list of offsets computed for a Use. Ideally this
+ /// list should be strictly ascending, but we ensure that only when we
+ /// actually translate the list of offsets to a RangeList.
+ struct OffsetInfo {
+ using VecTy = SmallVector<AA::RangeTy>;
+ // A map to store depth 1 predecessors per offset.
+ using OriginsTy = SmallVector<SmallPtrSet<Value *, 4>>;
+ using const_iterator = VecTy::const_iterator;
+ OriginsTy Origins;
+ VecTy Ranges;
+
+ const_iterator begin() const { return Ranges.begin(); }
+ const_iterator end() const { return Ranges.end(); }
+
+ bool operator==(const OffsetInfo &RHS) const {
+ return Ranges == RHS.Ranges && Origins == RHS.Origins;
+ }
+
+ bool operator!=(const OffsetInfo &RHS) const { return !(*this == RHS); }
+
+ void insert(AA::RangeTy Range, Value &V) {
+
+ auto *It = std::find(Ranges.begin(), Ranges.end(), Range);
+
+ // Offset exists in Offsets map
+ if (It != Ranges.end()) {
+ size_t Index = It - Ranges.begin();
+ if (Index < Origins.size())
+ Origins[Index].insert(&V);
+ } else {
+ Ranges.push_back(Range);
+ Origins.emplace_back();
+ Origins.back().insert(&V);
+ }
+ }
+
+ void setSizeAll(uint64_t Size) {
+ for (auto &Range : Ranges)
+ Range.Size = Size;
+ }
+
+ void getOnlyOffsets(SmallVector<int64_t> &Offsets) {
----------------
shiltian wrote:
put document on those functions that are not trivial to understand by their names
https://github.com/llvm/llvm-project/pull/96526
More information about the llvm-commits
mailing list