[llvm] [NVPTX] Cleanup NVPTXLowerArgs, simplifying logic and improving alignment propagation (PR #180286)

Alex MacLean via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 12 20:15:13 PST 2026


================
@@ -425,27 +405,26 @@ static CallInst *createNVVMInternalAddrspaceWrap(IRBuilder<> &IRB,
     ArgInParam->addRetAttr(
         Attribute::getWithAlignment(ArgInParam->getContext(), *ParamAlign));
 
+  Arg.addAttr(Attribute::get(Arg.getContext(), "nvvm.grid_constant"));
+  Arg.addAttr(Attribute::ReadOnly);
----------------
AlexMaclean wrote:

Yes, we do have this guarantee. Either it will be only loaded, or grid_constant or we're replacing all it's uses with an alloca. We cannot add NoCapture because grid_constants can be captured. 

> Ideally, earlier passes will already have added this attribute.

In some cases, such as inserting an alloca, this pass is changing the IR in order to make the param readonly. So an earlier pass could not infer this. Maybe a latter pass could to some value-tracking and figure it out, but I think it's appropriate to add the attribute here as part of the lowering. 

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


More information about the llvm-commits mailing list