-
Notifications
You must be signed in to change notification settings - Fork 13.3k
rustc_mir: don't build unused unwind cleanup blocks #43576
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
Conversation
The unused blocks are removed by SimplifyCfg, but they can cause a significant performance slowdown before they are removed.
I saw MIR cache invalidation somewhat hot on my profiler when per-BB indexin was used. That shouldn't matter much, but there is no good reason not to use an iterator.
Removing nops can allow more basic blocks to be merged, but merging basic blocks can't allow for more nops to be removed, so we should remove nops first. This doesn't matter *that* much, because normally we run SimplifyCfg several times, but there's no reason not to do it.
r=me with the Travis build fixed |
src/librustc_mir/build/scope.rs
Outdated
// If we are emitting a `drop` statement, we need to have the cached | ||
// diverge cleanup pads ready in case that drop panics. | ||
let may_panic = | ||
self.scopes[(len - scope_count)..].iter().any(|s| s.drops.iter().any(|s| s.kind.may_panic())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is >100 chars, failing tidy
. (I consider a for-loop + break is easier to read here.)
[00:03:50] tidy error: /checkout/src/librustc_mir/build/scope.rs:390: line longer than 100 chars
[00:03:51] some tidy checks failed
@bors r=eddyb |
📌 Commit ce0ca76 has been approved by |
rustc_mir: don't build unused unwind cleanup blocks When building a scope exit, don't build unwind cleanup blocks unless they will actually be used by the unwind path of a drop - the unused blocks are removed by SimplifyCfg, but they can cause a significant performance slowdown before they are removed. That fixes #43511. Also a few other small MIR cleanups & optimizations. r? @eddyb
☀️ Test successful - status-appveyor, status-travis |
When building a scope exit, don't build unwind cleanup blocks unless they will actually be used by the unwind path of a drop - the unused blocks are removed by SimplifyCfg, but they can cause a significant performance slowdown before they are removed. That fixes #43511.
Also a few other small MIR cleanups & optimizations.
r? @eddyb