[llvm] [NVPTX][InferAS] assume alloca instructions are in local AS (PR #121710)

Alex MacLean via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 24 14:35:49 PST 2025


================
@@ -562,4 +563,11 @@ Value *NVPTXTTIImpl::rewriteIntrinsicWithAddressSpace(IntrinsicInst *II,
   }
   }
   return nullptr;
-}
\ No newline at end of file
+}
+
+unsigned NVPTXTTIImpl::getAssumedAddrSpace(const Value *V) const {
+  if (isa<AllocaInst>(V))
+    return ADDRESS_SPACE_LOCAL;
+
----------------
AlexMaclean wrote:

@Artem-B were there other concerns you had with moving allocas to non-0 AS?

Even if we want to go this route I fear it will be pretty difficult and invasive. `getAssumedAddrSpace` is supposed to return the true AS of a given value in the AS 0. Handling this case there doesn't preclude moving allocas to non-0 AS in the future. I think it is good to add this check regardless to make InferAS make robust to different possible IRs. 

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


More information about the llvm-commits mailing list