[llvm] [llvm] Support invariant.load on readonly intrinsics (PR #205916)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 27 06:11:55 PDT 2026


dtcxzyw wrote:

> I'm not really sure I understand what the second semantics that you have in mind here are.

The second semantics is bound to the provenance.

+1 for dropping `invariant.end`. Then I don't have further concerns about the global invariance property.

> Generalizing this to arbitrary calls, we have some complications:
What about memory that is written? There could be an interpretation where only memory that's read is invariant, but writes are still allowed. This is probably not a practically useful interpretation. So either writes in an operation with !invariant.load are UB, or it's not well-formed in the first place. The latter probably makes most sense.
What about memory that is internal to the call? If I have an alloca inside the function, can I arbitrarily read and write it? I think the answer to that must be "yes".
I don't see a fundamental problem with semantics that depend on what memory is accessed during a call, but I'm also not sure it's worth the complication. 

In llubi, we can assign a generation number to each allocation. Allocations that were created after the entry of callee with `!invarant.load` will not be tainted.


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


More information about the llvm-commits mailing list