[llvm] [NVPTX] Lower allocas to the local address space (PR #204346)
Alex MacLean via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 9 08:47:01 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)
----------------
AlexMaclean wrote:
This doesn't really make sense. In SDAG value types don't hold an addrspace so we're just comparing the size here. That would work for `nvptx64` with `shortprs` enabled but isn't a general solution since LOCAL and GENERIC can have the same size. Should we just remove the cast and trust the lowering pass?
https://github.com/llvm/llvm-project/pull/204346
More information about the llvm-commits
mailing list