[llvm] [AMDGPU] Correctly merge noalias scopes during lowering of LDS data. (PR #131664)
Stanislav Mekhanoshin via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 25 01:03:52 PDT 2025
================
@@ -1451,7 +1452,17 @@ class AMDGPULowerModuleLDS {
I->setMetadata(LLVMContext::MD_alias_scope, AS);
MDNode *NA = I->getMetadata(LLVMContext::MD_noalias);
- NA = (NA ? MDNode::intersect(NA, NoAlias) : NoAlias);
+ // If domain of NoAlias (domain of LDS structure) is different
+ // than existing NA, we need to preserve exising !NoAlias
+ SmallPtrSet<const MDNode *, 16> ExistingDomains, LDSDomains;
+ ScopedNoAlias.collectScopedDomains(NA, ExistingDomains);
+ ScopedNoAlias.collectScopedDomains(NoAlias, LDSDomains);
+ auto Diff = set_difference(ExistingDomains, LDSDomains);
+ if (Diff.empty()) {
+ NA = NA ? MDNode::intersect(NA, NoAlias) : NoAlias;
+ } else {
+ NA = NA ? MDNode::concatenate(NA, NoAlias) : NoAlias;
----------------
rampitec wrote:
The code computes existing domains, but then resulting NA computation does not depend on it, it still uses the same NA and does not really use Diff or ExistingDomains. It is just replacing intersection with the concatenation, but not with the pre-existing info. What am I missing?
https://github.com/llvm/llvm-project/pull/131664
More information about the llvm-commits
mailing list