[llvm] Attributor: Infer noalias.addrspace metadata for memory instructions (PR #136553)

via llvm-commits llvm-commits at lists.llvm.org
Tue May 6 19:55:06 PDT 2025


================
@@ -12780,6 +12781,214 @@ struct AAAddressSpaceCallSiteArgument final : AAAddressSpaceImpl {
 };
 } // namespace
 
+/// ------------------------ No Alias Address Space  ---------------------------
+namespace {
+struct AANoAliasAddrSpaceImpl : public AANoAliasAddrSpace {
+  AANoAliasAddrSpaceImpl(const IRPosition &IRP, Attributor &A)
+      : AANoAliasAddrSpace(IRP, A) {}
+
+  void initialize(Attributor &A) override {
+    assert(getAssociatedType()->isPtrOrPtrVectorTy() &&
+           "Associated value is not a pointer");
+
+    if (!A.getInfoCache().getFlatAddressSpace().has_value()) {
+      resetASRanges(A);
+      indicatePessimisticFixpoint();
+      return;
+    }
+
+    unsigned FlatAS = A.getInfoCache().getFlatAddressSpace().value();
+    resetASRanges(A);
+    removeAS(FlatAS);
+
+    unsigned AS = getAssociatedType()->getPointerAddressSpace();
+    if (AS != FlatAS) {
+      removeAS(AS);
+      indicateOptimisticFixpoint();
+    }
----------------
Shoreshen wrote:

Hi @arsenm , this simply indicate the attribute is at fix point and stops further calculation.

The `removeAS(AS)` maybe can be removed

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


More information about the llvm-commits mailing list