[PATCH] D110049: [AMDGPU] Correctly merge alias.scope and noalias metadata for memops

Brendon Cahoon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 19 18:27:33 PDT 2021


bcahoon created this revision.
bcahoon added reviewers: rampitec, arsenm.
Herald added subscribers: foad, jeroen.dobbelaere, kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl.
bcahoon requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

When adding alias.scope and noalias metadata to a memcpy function,
the alias.scope and noalias metadata from the operands are merged.
The rule for merging alias.scope is to take the intersection of
the domains and the union of the scopes within those domains.
The rule for merging noalias is to take the intersection.

The bug is that AMDGPULowerModuleLDS was using concatenation for
both alias.scope and noalias. For example, when f1 and f2 are added
to the LDS structure and there is a memcpy(f2, f1, sizeof(f1)).
Then, concatenation creates noalias metadata for the memcpy that
includes both {f1, f2}. That means that the memcpy is assumed
not to alias a prior load of f2, which enables the optimizer to
remove a load of f2 that occurs after mempcy.

The function MDNode::getmostGenericAliasScope defines the semantics
for alias.scope. There is a function, combineMetadata in Local.cpp,
that uses intersect for noalias.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110049

Files:
  llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
  llvm/test/CodeGen/AMDGPU/lower-lds-struct-aa-memcpy.ll
  llvm/test/CodeGen/AMDGPU/lower-lds-struct-aa-merge.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110049.373482.patch
Type: text/x-patch
Size: 7225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210920/1d556614/attachment.bin>


More information about the llvm-commits mailing list