[llvm] [AMDGPU] Fix noalias metadata for calls that capture a pointer earlier (PR #219887)
Arseniy Obolenskiy via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 14 05:18:05 PDT 2026
================
@@ -100,13 +100,21 @@ static void addAliasScopeMetadata(Function &F, const DataLayout &DL,
// If instruction accesses memory, collect its pointer arguments.
Instruction *I = &(*Inst);
SmallVector<const Value *, 2u> PtrArgs;
+ // May reach a noalias argument via a copy captured before the call.
+ bool IsUnrestrictedCall = false;
if (std::optional<MemoryLocation> MO = MemoryLocation::getOrNone(I))
PtrArgs.push_back(MO->Ptr);
else if (const CallBase *Call = dyn_cast<CallBase>(I)) {
- if (Call->doesNotAccessMemory())
+ MemoryEffects ME = Call->getMemoryEffects();
+ if (ME.doesNotAccessMemory())
continue;
+ // Inaccessible memory cannot alias any IR-visible pointer.
+ if (ME.onlyAccessesInaccessibleMem())
+ continue;
+ IsUnrestrictedCall = !ME.onlyAccessesArgPointees();
----------------
aobolensk wrote:
No. If nothing escapes, the capture check finds nothing and `!noalias` is still added
Only `!alias.scope` is dropped, since such a call can touch memory beyond its arguments
https://github.com/llvm/llvm-project/pull/219887
More information about the llvm-commits
mailing list