[llvm] [AMDGPU] Fix spurious NoAlias results (PR #122309)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 9 09:06:33 PST 2025
================
@@ -80,10 +80,13 @@ AliasResult AMDGPUAAResult::alias(const MemoryLocation &LocA,
} else if (const Argument *Arg = dyn_cast<Argument>(ObjA)) {
const Function *F = Arg->getParent();
switch (F->getCallingConv()) {
- case CallingConv::AMDGPU_KERNEL:
+ case CallingConv::AMDGPU_KERNEL: {
// In the kernel function, kernel arguments won't alias to (local)
// variables in shared or private address space.
- return AliasResult::NoAlias;
+ const auto *ObjB =
+ getUnderlyingObject(B.Ptr->stripPointerCastsForAliasAnalysis());
+ return (ObjA == ObjB) ? AliasResult::MustAlias : AliasResult::NoAlias;
----------------
nikic wrote:
You can't return MustAlias for an underlying object comparison, as that strips offsets.
Generally, I don't really understand this change or what the actual rule here is supposed to be. The old code makes sense if your IR is UB. If it isn't, then the logic here probably needs to be more along the lines of using the address space of an *identified* underlying object instead of the address space of the original pointer. Basing logic on a comparison of non-identified objects is fishy.
https://github.com/llvm/llvm-project/pull/122309
More information about the llvm-commits
mailing list