[llvm] [polly] [AST] Don't merge memory locations in AliasSetTracker (PR #65731)

Bruno De Fraine via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 02:16:40 PST 2023


================
@@ -207,66 +118,21 @@ class AliasSet : public ilist_node<AliasSet> {
 
   // Alias Set iteration - Allow access to all of the pointers which are part of
   // this alias set.
-  class iterator;
-  iterator begin() const { return iterator(PtrList); }
-  iterator end()   const { return iterator(); }
-  bool empty() const { return PtrList == nullptr; }
+  using iterator = std::vector<MemoryLocation>::const_iterator;
+  iterator begin() const { return MemoryLocs.begin(); }
+  iterator end()   const { return MemoryLocs.end(); }
----------------
brunodf-snps wrote:

The source of the const-casts is not the const-iterator, it is [inside `MemoryLocation`](https://github.com/llvm/llvm-project/blob/617ee255cab59598600f453f9e80091aa203324b/llvm/include/llvm/Analysis/MemoryLocation.h#L230).

I think it would be possible to provide a convenience version of `getPointers` that integrates the const-cast so the client would not be burdened with this, but the caller would still be responsible to ensure the cast is valid. Is there a precedent of this in LLVM? I'm only aware of methods that intregrate const-casts when we know it is valid ([example](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Analysis/ValueTracking.h#L681-L685)).

https://github.com/llvm/llvm-project/pull/65731


More information about the llvm-commits mailing list