[llvm] [IR] Introduce !captures metadata (PR #160913)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 27 07:39:30 PDT 2025
dtcxzyw wrote:
> The motivating use case for this is Rust's println!() machinery, which involves storing a reference to the value inside a structure. This means that printing code (including conditional debugging code), can inhibit optimizations because the pointer escapes. With the new metadata we can annotate this as a read-only capture, which has less impact on optimizations.
https://godbolt.org/z/T1479EG43
I am curious about how we annotate this in Rust. Do we provide an intrinsic like `declare ptr @foo(ptr returned captures(address, read_provenance))` in Rust? cc @RalfJung @scottmcm
Anyway, from the LLVM side, I think it is profitable as we can salvage the capture information after inlining.
https://github.com/llvm/llvm-project/pull/160913
More information about the llvm-commits
mailing list