[llvm] [NVPTX] Lower allocas to the local address space (PR #204346)

Tim Besard via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 10 02:01:15 PDT 2026


================
@@ -1686,10 +1686,14 @@ SDValue NVPTXTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
                   {Chain, DAG.getZExtOrTrunc(Size, DL, LocalVT),
                    DAG.getTargetConstant(Align, DL, MVT::i32)});
 
-  SDValue ASC = DAG.getAddrSpaceCast(
-      DL, Op.getValueType(), Alloc, ADDRESS_SPACE_LOCAL, ADDRESS_SPACE_GENERIC);
-
-  return DAG.getMergeValues({ASC, SDValue(Alloc.getNode(), 1)}, DL);
+  // Keep the result in the alloca's address space: return the local pointer as
+  // is when that is requested (escapes are cast by the caller), else cast it.
+  SDValue Ptr = Alloc;
+  if (Op.getValueType() != LocalVT)
----------------
maleadt wrote:

Okay, I'll push a commit removing the cast and replacing it by an assert

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


More information about the llvm-commits mailing list