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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon May 5 10:21:49 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();
+    }
----------------
arsenm wrote:

Does this do anything useful? If the direct memory access type isn't flat, there's no point in setting this. If this is coming from an addrspacecast at the use point, we would have folded it to the direct address space in the first place

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


More information about the llvm-commits mailing list