Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit optimization remarks to the final binary, not the console #96705

Open
tschuett opened this issue May 4, 2022 · 4 comments
Open

Emit optimization remarks to the final binary, not the console #96705

tschuett opened this issue May 4, 2022 · 4 comments
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tschuett
Copy link

tschuett commented May 4, 2022

Since #90833 rustc prints remarks with -Cremark to the console.

LLVM can include the remarks into the executable. Then you can read the remarks and analyze them.

https://llvm.org/docs/Remarks.html

I never managed to thread the flags through rustc.

@matthiaskrgr
Copy link
Member

RUSTFLAGS="-C llvm-args=--pass-remarks=.* -Cdebuginfo=2" cargo build --release

does that work for you?

@tschuett
Copy link
Author

tschuett commented May 4, 2022

It still pollutes my console.

@tschuett
Copy link
Author

tschuett commented May 4, 2022

RUSTFLAGS="-C llvm-args=--pass-remarks-output=filename -Cdebuginfo=2" cargo build --release

This fails because rustc does not know about: pass-remarks-output

@jyn514 jyn514 changed the title remarks Emit optimization remarks to the final binary, not the console Apr 9, 2023
@jyn514 jyn514 added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-codegen Area: Code generation labels Apr 9, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 6, 2023
Output LLVM optimization remark kind in `-Cremark` output

Since rust-lang#90833, the optimization remark kind has not been printed. Therefore it wasn't possible to easily determine from the log (in a programmatic way) which remark kind was produced. I think that the most interesting remarks are the missed ones, which can lead users to some code optimization.

Maybe we could also change the format closer to the "old" one:
```
note: optimization remark for tailcallelim at /checkout/src/libcore/num/mod.rs:1:0: marked this call a tail call candidate
```

I wanted to programatically parse the remarks so that they could work e.g. with https://github.com/OfekShilon/optview2. However, now that I think about it, probably the proper solution is to tell rustc to output them to YAML and then use the YAML as input for the opt remark visualization tools. The flag for enabling this does not seem to work though (rust-lang#96705 (comment)).

Still I think that it's good to output the remark kind anyway, it's an important piece of information.

r? `@tmiasko`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 6, 2023
Output LLVM optimization remark kind in `-Cremark` output

Since rust-lang#90833, the optimization remark kind has not been printed. Therefore it wasn't possible to easily determine from the log (in a programmatic way) which remark kind was produced. I think that the most interesting remarks are the missed ones, which can lead users to some code optimization.

Maybe we could also change the format closer to the "old" one:
```
note: optimization remark for tailcallelim at /checkout/src/libcore/num/mod.rs:1:0: marked this call a tail call candidate
```

I wanted to programatically parse the remarks so that they could work e.g. with https://github.com/OfekShilon/optview2. However, now that I think about it, probably the proper solution is to tell rustc to output them to YAML and then use the YAML as input for the opt remark visualization tools. The flag for enabling this does not seem to work though (rust-lang#96705 (comment)).

Still I think that it's good to output the remark kind anyway, it's an important piece of information.

r? ``@tmiasko``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 6, 2023
Output LLVM optimization remark kind in `-Cremark` output

Since rust-lang#90833, the optimization remark kind has not been printed. Therefore it wasn't possible to easily determine from the log (in a programmatic way) which remark kind was produced. I think that the most interesting remarks are the missed ones, which can lead users to some code optimization.

Maybe we could also change the format closer to the "old" one:
```
note: optimization remark for tailcallelim at /checkout/src/libcore/num/mod.rs:1:0: marked this call a tail call candidate
```

I wanted to programatically parse the remarks so that they could work e.g. with https://github.com/OfekShilon/optview2. However, now that I think about it, probably the proper solution is to tell rustc to output them to YAML and then use the YAML as input for the opt remark visualization tools. The flag for enabling this does not seem to work though (rust-lang#96705 (comment)).

Still I think that it's good to output the remark kind anyway, it's an important piece of information.

r? ```@tmiasko```
@Kobzol
Copy link
Contributor

Kobzol commented Jul 6, 2023

With #113040, remarks can now be outputted into a directory, in the same (YAML) format as clang outputs them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants