[llvm] [LangRef] Clarify what "group" in invariant.group means. (PR #200552)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 05:58:56 PDT 2026
https://github.com/nikic approved this pull request.
LGTM. This seems kind of obvious to me, but I guess it doesn't hurt to mention it explicitly.
FWIW, the definition of `!invariant.group` really needs a larger change, because talking about "same pointer operand" is semantically incoherent. The text explicitly treats bitcast and zero-index GEP as "same", but obviously there are many other ways in which operations can be folded away such that SSA value identity is not preserved.
Even just replacing this with "the same provenance" would be incorrect, because operations that create derived provenance may be elided, e.g. as a result of inlining.
I think the actual semantics here look something like this:
> Let `%p` be the pointer accessed by an instruction with `!invariant.group` metadata. If the accessed memory location is later written, through a pointer that is *invariant-compatible* with `%p`, then the behavior is undefined. Two pointers are *invariant-compatible* if their provenance has a common ancestor that does not require crossing an `llvm.strip.invariant` or `llvm.launder.invariant` intrinsic.
https://github.com/llvm/llvm-project/pull/200552
More information about the llvm-commits
mailing list