Open
Description
I'd like Rust to dump standard LLVM compiler statistics via
$ cat test.rs
#[no_mangle]
pub fn foo(v: &[i32], n: usize) -> i32 {
let mut ans = 0;
for i in 0..n {
ans += v[i];
}
ans
}
$ rustc --crate-type=rlib -O -C target-cpu=native -C llvm-args=--stats test.rs
but this does not work (output is empty).
This
$ rustc --crate-type=rlib -O -C target-cpu=native --emit=llvm-ir test.rs
$ ~/rust/build/x86_64-unknown-linux-gnu/ci-llvm/bin/opt test.ll --stats -O2 -o test.bc
===-------------------------------------------------------------------------===
... Statistics Collected ...
===-------------------------------------------------------------------------===
6 aa - Number of NoAlias results
12 basicaa - Number of times a GEP is decomposed
1 count-visits - Max number of times we visited a function
4 globalsmodref-aa - Number of functions that do not access memory
...
works but of course is irrelevant because opt's pipeline is unrelated to rustc.
I tried both stable:
$ rustc --version
rustc 1.87.0 (17067e9ac 2025-05-09)
and nightly
$ rustc --version
rustc 1.89.0-nightly (6ccd44760 2025-06-08)