Repository navigation
Conversation
Let's make some editorial fixes and revisions to the tweaked note about the `optimize` attribute.
The note says that `optimize(size)` and `optimize(speed)` don't do much at `-C opt-level=0` or at `-C opt-level=1`. That's true for `-C opt-level=0`. But at `-C opt-level=1`, the compiler does meaningful optimization, and `optimize(size)` meaningfully affects the results. Let's trim the claim to `-C opt-level=0` only.
We say that `-C opt-level=0` disables most of the LLVM optimization pipeline. Let's be more precise and say exactly what it doesn't disable.
The `optimize` attribute affects both optimization and code generation. What we're saying in this note is most accurate if scoped to speak only about the effect on optimization, so let's scope it in that way.
In the note, we say that marking a function with `optimize(size)` affects optimization at `-C opt-level=2` and higher. But that's incomplete. It actually affects optimization at all levels other than `-C opt-level=0` and `-C opt-level=z`. Let's say that.
There's more to the story of the `optimize` attribute than just the effect on optimization. It also affects code generation. Let's discuss this in a new note.
Contributor
|
Thanks @RalfJung. I've pushed some revisions. (The situation is always a bit more complicated.) Please have a look. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I found it odd that the comment for
optimize(size/speed)is so far away from the one foroptimize(none), so I moved it down and also updated it based on the discussion on Zulip.Also see rust-lang/rust#166002 which adjusts rustc to make mir-opt and LLVM behavior more consistent.