[PATCH] D124787: [NVPTX] Implement NVPTX AliasAnalysis

Andrew Savonichev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 16:44:53 PST 2023


asavonic added inline comments.


================
Comment at: llvm/test/CodeGen/NVPTX/nvptx-aa.ll:82
+; CHECK-ALIAS: MayAlias: i8* %gen, i8 addrspace(1)* %global
+; CHECK-ALIAS: NoAlias:  i8 addrspace(1)* %global, i8 addrspace(101)* %param
+; CHECK-ALIAS: MayAlias: i8* %gen, i8 addrspace(101)* %param
----------------
tra wrote:
> asavonic wrote:
> > tra wrote:
> > > Looks like recently PTX grew ability to convert .param to generic AS:
> > > https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cvta
> > > 
> > > AFAICT, when that happens, the address *may* be converted into a global pointer:
> > > https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#generic-addressing says:
> > > 
> > > > The Kernel Function Parameters (.param) window is contained within the .global window.
> > > 
> > > So, technically, a global pointer *may* alias with a param pointer on some GPUs via ASC(param->generic->global).
> > > 
> > > The good news is that we don't have `cvta.param` implemented yet, so as things stand, there's no aliasing between param and global, but that will likely change in the future. We may want to either conservatively make them "mayAlias" from now on, or keep them as "NoAlias" for now with a TODO to make sure we update it when we get to implement `cvta.param` in lib/Target/NVPTX/NVPTXIntrinsics.td
> > > 
> > Hmm.. this is unfortunate. If `param` is a subset of `global`, then it also cannot be treated as constant memory. I'll update `alias` and `getModRefInfoMask` functions to handle this.
> .param AS is a bit special when it comes to constantness.
> 
> Param space should not ever be used in the user-provided IR.  As far as the user IR is concerned, byval arguments live in generic AS and are writeable.
> 
> In order to make sure byval arguments are never written to, as required by PTX,  we make a local copy, if one needs to store to it. From that point of view, AS should also consider param space as writable, even though we'll never generate actual writes to it and redirect them to a local copy.
> 
> 
> 
Ok, to summarize:

1) NVPTXLowerArgs does not allow any writes or pointer copies of param pointers by redirecting them to a local copy.

2) `cvta.param` (PTX 7.7+ and SM_70+) is not implemented, and therefore we have no way to cast it to generic and avoid the redirect (1).

So while both these implementation details are true, param pointers point to "constant" memory (there are no writes to it), and do not alias with anything except for other param pointers.

I guess we can put a TODO explaining this for now. Once NVPTXLowerArgs is changed to support `cvta.param` we'll have to re-evaluate this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124787/new/

https://reviews.llvm.org/D124787



More information about the llvm-commits mailing list