[llvm] [IR] Introduce captures attribute (PR #116990)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 26 01:59:17 PST 2024


nikic wrote:

> > I'm not really sure what your godbolt example is supposed to show (I don't see any relation to provenance capture?)
> 
> `icmp ptr eq %p, %q` doesn't allow us to perform GVN for `load %p` and `load %q`, right? Another alive2 counterexample: [AliveToolkit/alive2#1110](https://github.com/AliveToolkit/alive2/issues/1110)

Yes, that's correct, because icmp only compares the pointer address. See https://github.com/llvm/llvm-project/pull/82458 for the relevant GVN change (we haven't propagated that one to some other places yet, like select folding).

Though I will note that the transform GCC does in your particular example is still correct (https://alive2.llvm.org/ce/z/EgWrbA): If `p` and `q` have the same provenance, then `*p == *q` is true. If they don't, then either `*p` or `*q` is undefined behavior, and returning true is a valid refinement. Clang doesn't try to handle this currently.

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


More information about the llvm-commits mailing list