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

Output LLVM optimization remark kind in -Cremark output #111203

Merged
merged 1 commit into from
May 7, 2023

Conversation

Kobzol
Copy link
Contributor

@Kobzol Kobzol commented May 4, 2023

Since #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 (#96705 (comment)).

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

r? @tmiasko

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 4, 2023
@tmiasko
Copy link
Contributor

tmiasko commented May 5, 2023

For programmatic use, the serialized format is definitely way to go. It can be configured with setupLLVMOptimizationRemarks.

@bors r+

@bors
Copy link
Contributor

bors commented May 5, 2023

📌 Commit 00ac29d has been approved by tmiasko

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 5, 2023
@Kobzol
Copy link
Contributor Author

Kobzol commented May 5, 2023

I was trying to force LLVM to output the remarks to yaml using LLVM flags, but I was unable to do it. Even using Clang, the only options that worked were -Rpass-missed and -fsave-optimization-record, but these are Clang flags, not LLVM flags. It seems that currently it's not possible to tell rustc to output remarks to yaml.

Could I add something like -Cremark-output= as a rustc flag? Or introduce some minisyntax to -Cremark to enable the serialized format? Or maybe we could do it through an environment variable?

@tmiasko
Copy link
Contributor

tmiasko commented May 5, 2023

Sure, sound good in general. Of those variants a new flag (or more?) seem the most appropriate.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request 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 pull request 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``
bors added a commit to rust-lang-ci/rust that referenced this pull request May 6, 2023
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#111002 (Fix the test directories suggested by `./x.py suggest`)
 - rust-lang#111077 (Make more ConstProp tests unit.)
 - rust-lang#111151 (check bootstrap scripts syntax)
 - rust-lang#111203 (Output LLVM optimization remark kind in `-Cremark` output)
 - rust-lang#111237 (asm: loongarch64: Implementation of clobber_abi)
 - rust-lang#111274 (Expand the LLVM coverage of `--print target-cpus`)
 - rust-lang#111289 (Check arguments length in trivial diagnostic lint)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit e4eaf31 into rust-lang:master May 7, 2023
@rustbot rustbot added this to the 1.71.0 milestone May 7, 2023
@Kobzol Kobzol deleted the remark-print-kind branch May 7, 2023 07:27
@riking
Copy link

riking commented May 11, 2023

Drive-by comment: use JSON, not YAML, for machine-produced and machine-read compile diagnostic outputs. If you wanted to output a human-editable configuration, TOML would fit with existing practice in Rust.

@Kobzol
Copy link
Contributor Author

Kobzol commented May 11, 2023

So in general, I agree with your comment. However, there are existing visualization tools for these optimization remarks (e.g. optview), and these work with a specific YAML format which is produced by LLVM. Therefore, to reuse the existing LLVM logic, I need to use its format. Otherwise we would need to come up with a new, custom format, which also wouldn't be compatible with the existing visualization tools. Therefore, I think that it might be better to just reuse the format that is already produced by LLVM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants