rust/compiler/rustc_codegen_ssa/src
Matthias Krüger 2734b5ada9
Rollup merge of #113723 - khei4:khei4/llvm-stats, r=oli-obk,nikic
Resurrect: rustc_llvm: Add a -Z `print-codegen-stats` option to expose LLVM statistics.

This resurrects PR https://github.com/rust-lang/rust/pull/104000, which has sat idle for a while. And I want to see the effect of stack-move optimizations on LLVM (like https://reviews.llvm.org/D153453) :).

I have applied the changes requested by `@oli-obk` and `@nagisa`  https://github.com/rust-lang/rust/pull/104000#discussion_r1014625377 and https://github.com/rust-lang/rust/pull/104000#discussion_r1014642482 in the latest commits.

r? `@oli-obk`

-----

LLVM has a neat [statistics](https://llvm.org/docs/ProgrammersManual.html#the-statistic-class-stats-option) feature that tracks how often optimizations kick in. It's very handy for optimization work. Since we expose the LLVM pass timings, I thought it made sense to expose the LLVM statistics too.

-----
(Edit: fix broken link
(Edit2: fix segmentation fault and use malloc

If `rustc` is built with
```toml
[llvm]
assertions = true
```
Then you can see like
```
rustc +stage1 -Z print-codegen-stats -C opt-level=3  tmp.rs
===-------------------------------------------------------------------------===
                          ... Statistics Collected ...
===-------------------------------------------------------------------------===
         3 aa                           - Number of MayAlias results
       193 aa                           - Number of MustAlias results
       531 aa                           - Number of NoAlias results
...
```

And the current default build emits only
```
$ rustc +stage1 -Z print-codegen-stats -C opt-level=3  tmp.rs
===-------------------------------------------------------------------------===
                          ... Statistics Collected ...
===-------------------------------------------------------------------------===
$
```
This might be better to emit the message to tell assertion flag necessity, but now I can't find how to do that...
2023-07-21 06:52:27 +02:00
..
back Rollup merge of #113723 - khei4:khei4/llvm-stats, r=oli-obk,nikic 2023-07-21 06:52:27 +02:00
debuginfo refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
mir Monomorphize constants before inspecting them 2023-07-20 08:53:09 +00:00
traits rustc_llvm: Add a -Z print-llvm-stats option to expose LLVM statistics. 2023-07-16 22:56:04 +09:00
base.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
codegen_attrs.rs Add the no-builtins attribute to functions when no_builtins is applied at the crate level. 2023-07-18 22:15:47 +08:00
common.rs Promote unchecked_add/sub/mul/shl/shr to mir::BinOp 2023-06-19 01:47:03 -07:00
errors.rs Add rustc option to output LLVM optimization remarks to YAML files 2023-07-02 13:41:36 +02:00
glue.rs Use size_of_val instead of manual calculation 2023-03-17 19:55:49 -07:00
lib.rs Move coverageinfo::ffi and coverageinfo::map out of SSA 2023-07-05 20:40:40 +10:00
meth.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
mono_item.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
target_features.rs support for mips32r6 as a target_arch value 2023-07-18 18:58:18 +08:00