[llvm] [AA] Teach getModRefInfo(FenceInst) to consult the AA chain (PR #192043)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 05:21:20 PDT 2026


michaelselehov wrote:

## Description

`AAResults::getModRefInfo(FenceInst, Loc)` currently only calls `getModRefInfoMask(Loc)` — a coarse filter based on location attributes. Unlike the `CallBase` path, it does not query individual AA passes, so scoped-noalias metadata (`!alias.scope` / `!noalias`) on fences is ignored.

This matters after `AMDGPULowerKernelArguments` (bd9668df0f00): `noalias readonly` kernel pointer arguments are replaced with loads from the kernarg segment and annotated with scoped-noalias metadata. The `readonly` attribute is lost in the process. When a `fence` carries matching `!noalias` metadata, `ScopedNoAliasAA` can prove the fence does not modify the kernarg memory — but only if `getModRefInfo` actually asks.

Without this patch, `MemorySSA` conservatively treats fences as clobbers of the kernarg loads, blocking redundant-load elimination and causing measurable regressions (e.g. ~20% GFLOPS drop in rocFFT on MI200).

### Changes

- Add `getModRefInfo(const FenceInst*, const MemoryLocation&, AAQueryInfo&)` to `Concept` / `Model` / `AAResultBase`, matching the existing `CallBase` pattern.
- Implement `ScopedNoAliasAAResult::getModRefInfo(FenceInst*)` — checks `!noalias` / `!alias.scope` metadata, gated by `-enable-scoped-noalias`.
- Rewrite `AAResults::getModRefInfo(FenceInst)` to iterate through registered AA passes, then apply `getModRefInfoMask` as a final filter.
- Add `using AAResultBase::getModRefInfo` to `BasicAAResult` and `TypeBasedAAResult` to prevent C++ name hiding.
- Add a lit test (`fence-noalias-metadata.ll`) with positive and negative cases for load vectorization across fences with/without scoped noalias metadata.


https://github.com/llvm/llvm-project/pull/192043


More information about the llvm-commits mailing list