[PATCH] D157451: [AMDGPU] Emit .actual_access metadata

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 11 23:44:22 PDT 2023


rampitec added inline comments.


================
Comment at: llvm/test/CodeGen/AMDGPU/hsa-metadata-deduce-ro-arg.ll:12
 ; CHECK-NEXT:   AddrSpaceQual:   Global
-; CHECK-NEXT:   AccQual:         ReadOnly
+; CHECK-NEXT:   AccQual:         Default
 ; CHECK-NEXT:   IsConst:         true
----------------
rampitec wrote:
> cfang wrote:
> > arsenm wrote:
> > > cfang wrote:
> > > > arsenm wrote:
> > > > > Seems like the mirror write only deduction test is missing
> > > > We currently only emit read_only for .actual_access.  Do you know what are the exact
> > > > conditions to emit "write_only" or "read_write"?  Thanks.
> > > > 
> > > >   if (Arg.getType()->isPointerTy() && Arg.onlyReadsMemory() &&
> > > >       Arg.hasNoAliasAttr()) {
> > > >     ActAccQual = "read_only";
> > > >   }
> > > Arg.onlyReadsMemory and Arg.hasAttribute(Attribute::WriteOnly) (don't know if you really need the noalias part here, it's probably a runtime workaround if you do)
> > @rampitec: Do you remember exactly why noalias is needed?  
> The fact that you do not write through this pointer and pointers derived from it does not tell that you do not write this memory. You can tell you don't if there can be no other pointers to that memory as well.
Like:
```
void foo(const int *p1, int *p2) {
  *p2 = p1[1];
}
```
This is wrong to assume that memory under p1 was not modified because you can call it like this:
```
foo(p, p);
```


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

https://reviews.llvm.org/D157451



More information about the llvm-commits mailing list