rust/compiler/rustc_codegen_gcc/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 Merge commit '08a6d6e16b' into sync-cg_gcc-2023-03-04 2023-03-05 12:03:19 -05:00
intrinsic refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
abi.rs Merge apply_attrs_callsite into call and invoke 2022-10-01 17:01:31 +00:00
allocator.rs Prevent insta-stable no alloc shim support 2023-05-11 14:35:09 +00:00
archive.rs Rewrite LLVM's archive writer in Rust 2022-11-26 19:35:32 +00:00
asm.rs Merge commit '1bbee3e217' into sync-cg_gcc-2023-06-19 2023-06-19 18:51:02 -04:00
attributes.rs Merge commit '1bbee3e217' into sync-cg_gcc-2023-06-19 2023-06-19 18:51:02 -04:00
base.rs Introduce MonoItemData. 2023-07-17 08:44:48 +10:00
builder.rs Merge commit '1bbee3e217' into sync-cg_gcc-2023-06-19 2023-06-19 18:51:02 -04:00
callee.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
common.rs Support 128-bit enum variant in debuginfo codegen 2023-06-10 03:39:24 +08:00
consts.rs Merge commit '1bbee3e217' into sync-cg_gcc-2023-06-19 2023-06-19 18:51:02 -04:00
context.rs Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
coverageinfo.rs Remove trait CoverageInfoMethods, since non-LLVM backends don't need it 2023-07-05 20:40:40 +10:00
debuginfo.rs Introduce composite debuginfo. 2022-11-15 17:53:50 +00:00
declare.rs Merge commit '1bbee3e217' into sync-cg_gcc-2023-06-19 2023-06-19 18:51:02 -04:00
errors.rs Fix for diagnostics 2023-03-05 12:31:16 -05:00
int.rs Merge commit '08a6d6e16b' into sync-cg_gcc-2023-03-04 2023-03-05 12:03:19 -05:00
lib.rs rustc_llvm: Add a -Z print-llvm-stats option to expose LLVM statistics. 2023-07-16 22:56:04 +09:00
mono_item.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
type_.rs Add cross-language LLVM CFI support to the Rust compiler 2023-05-03 22:41:29 +00:00
type_of.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00