[llvm] [RFC] IR: Define noalias.addrspace metadata (PR #102461)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 15 05:50:27 PDT 2024
================
@@ -5180,6 +5206,13 @@ void Verifier::visitInstruction(Instruction &I) {
visitRangeMetadata(I, Range, I.getType());
}
+ if (MDNode *Range = I.getMetadata(LLVMContext::MD_noalias_addrspace)) {
+ Check(isa<LoadInst>(I) || isa<StoreInst>(I) || isa<AtomicRMWInst>(I) ||
+ isa<AtomicCmpXchgInst>(I) || isa<CallInst>(I),
+ "noalias.addrspace are only for memory operations!", &I);
+ visitNoaliasAddrspaceMetadata(I, Range, I.getType());
----------------
arsenm wrote:
The intent was to only restrict the underlying object's address space, which is most obviously definable in terms of generic IR rules we already have.
The IR has no generic rules for address space aliasing relationships. Any address space is assumed to potentially alias any other address space, and this is only relaxed by target AliasAnalysis extensions. An accessing LoadInst with an explicit noalias.addrspace forbidding the exact address space of the load has to be assumed valid, as we know nothing about what address spaces can alias others.
> If this set happens to be empty, then I'd think the IR is invalid (we have not left any address space for the load to do its memory access. Or maybe undefined)?
We can't make these situations invalid IR without requiring more target information in the IR, which I want to avoid. The assumption is the IR producer knows what it's doing for the target, and any address space value may have been produced through a valid chain of addrspacecasts.
I've tried to reword the LangRef to be more explicit this only says anything about the original object's address space, not the access
https://github.com/llvm/llvm-project/pull/102461
More information about the llvm-commits
mailing list