Uh oh!
There was an error while loading. Please reload this page.
Avoid unnecessary basic blocks for allocas, return and else - #7763
Merged
Conversation
dotdash
commented
Jul 13, 2013
ContributorAuthor
This currently results in worse optimized code :-/ |
pcwalton
commented
Jul 13, 2013
Contributor
How much worse? I'm inclined to merge it anyway if it's fine. |
graydon
commented
Jul 13, 2013
Contributor
Likewise, curious how much worse we're talking. Does it compile any faster on O0? |
dotdash
commented
Jul 13, 2013
ContributorAuthor
Up to about 7% slower in some cases. Looks like it's due to the fact that the final function block doesn't reuse the "return" cleanup path anymore. Trying to fix that now. |
Currently, we always create a dedicated "return" basic block, but when there's only a single predecessor for that block, it can be merged with that predecessor. We can achieve that merge by only creating the return block on demand, avoiding its creation when its not required. Reduces the pre-optimization size of librustc.ll created with --passes "" by about 90k lines which equals about 4%.
When there are no allocas, we don't need a block for them.
If an "if" expression has no "else", we don't have to create an LLVM basic block either.
dotdash
commented
Jul 13, 2013
ContributorAuthor
The new version shows no visible performance regression with |
dotdash
commented
Jul 13, 2013
ContributorAuthor
Build times for unoptimized libstd build with an unoptimized rustc: Before After |
graydon
commented
Jul 13, 2013
Contributor
Great! |
bors added a commit
that referenced
this pull request
Jul 13, 2013
These commits remove a bunch of empty or otherwise unnecessary blocks, reducing the size of the pre-optimization IR and improving its readability. `librustc.ll` created with `--passes ""` shrinks by about 120k lines which equals about 5% of the total size.
U007D pushed a commit
to U007D/rust-mos
that referenced
this pull request
Aug 21, 2026
8947: Correctly resolve crate name in use paths when import shadows it r=Veykril a=Veykril Fixesrust-lang#7763 bors r+ Co-authored-by: Lukas Tobias Wirth <lukastw97@gmail.com>
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 freeto 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.
These commits remove a bunch of empty or otherwise unnecessary blocks, reducing the size of the pre-optimization IR and improving its readability.
librustc.llcreated with--passes ""shrinks by about 120k lines which equals about 5% of the total size.