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

Fix the invalidation of the MIR early exit cache #35751

Merged
merged 2 commits into from
Aug 18, 2016

Conversation

nagisa
Copy link
Member

@nagisa nagisa commented Aug 17, 2016

The #34307 introduced a cache for early exits in order to help with O(n*m) explosion of cleanup blocks but the cache is invalidated incorrectly and I can’t seem to figure out why (caching is hard!)

Remove the cache for now to fix the immediate correctness issue and worry about the performance later.

Cache invalidation got fixed.

Fixes #35737

r? @nikomatsakis

@eddyb
Copy link
Member

eddyb commented Aug 17, 2016

I'm not seeing any invalidation at all for cached_exits, seems that it's just missing?

@nagisa
Copy link
Member Author

nagisa commented Aug 17, 2016

@eddyb it was here

@eddyb
Copy link
Member

eddyb commented Aug 17, 2016

@nagisa Oops, I see. I would've expected .clear() instead of throwing it away.

@arielb1
Copy link
Contributor

arielb1 commented Aug 17, 2016

@bors r+

@bors
Copy link
Contributor

bors commented Aug 17, 2016

📌 Commit e1749af has been approved by arielb1

@arielb1
Copy link
Contributor

arielb1 commented Aug 17, 2016

I would prefer to keep the cache through.

@nagisa nagisa force-pushed the mir-scope-fix-again branch 2 times, most recently from 85c4e5d to 44955c7 Compare August 17, 2016 16:05
@nagisa
Copy link
Member Author

nagisa commented Aug 17, 2016

Cache invalidation fixed.

@eddyb eddyb changed the title Remove the early exit cache Fix the invalidation of the MIR early exit cache Aug 17, 2016
// will stay correct, because the already generated unwind blocks cannot be influenced
// by just added drop.
let this_scope = scope.extent == extent;
scope.invalidate_cache(!this_scope);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will invalidate the unwind cache in cases other than DropKind::Value, which is undesirable (as StorageDead doesn't end up on the unwind path at all).

@eddyb eddyb added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Aug 17, 2016
@nagisa nagisa force-pushed the mir-scope-fix-again branch 3 times, most recently from 112a3e1 to 9983aef Compare August 17, 2016 16:21
// If we’re scheduling cleanup for non-droppable type (i.e. DropKind::Storage), then we
// do not need to invalidate unwind branch, because DropKind::Storage does not end up
// built in the unwind branch currently.
let invalidate_unwind = needs_drop || !this_scope;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be &&, not ||.

@nagisa nagisa force-pushed the mir-scope-fix-again branch from 9983aef to 2d36642 Compare August 17, 2016 18:09
@eddyb
Copy link
Member

eddyb commented Aug 17, 2016

@bors r+

@bors
Copy link
Contributor

bors commented Aug 17, 2016

📌 Commit 2d36642 has been approved by eddyb

if scope.extent == extent {
let this_scope = scope.extent == extent;
// We must invalidate all the caches leading up to the scope we’re looking for, because
// the cached blocks will branch into build of scope not containing the new drop. If we
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a hard time following this comment, I'm afraid. Ideal would be a diagram, but maybe we can just tweak the wording...I don't quite know how since I don't understand it yet :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll try to draw something up.

@nagisa nagisa force-pushed the mir-scope-fix-again branch from e08d0cd to 2c3250a Compare August 17, 2016 21:42
@eddyb
Copy link
Member

eddyb commented Aug 17, 2016

@bors r+

@bors
Copy link
Contributor

bors commented Aug 17, 2016

📌 Commit 2c3250a has been approved by eddyb

eddyb added a commit to eddyb/rust that referenced this pull request Aug 18, 2016
Fix the invalidation of the MIR early exit cache

~~The rust-lang#34307 introduced a cache for early exits in order to help with O(n*m) explosion of cleanup blocks but the cache is invalidated incorrectly and I can’t seem to figure out why (caching is hard!)~~

~~Remove the cache for now to fix the immediate correctness issue and worry about the performance later.~~

Cache invalidation got fixed.

Fixes rust-lang#35737

r? @nikomatsakis
bors added a commit that referenced this pull request Aug 18, 2016
Rollup of 12 pull requests

- Successful merges: #35346, #35734, #35739, #35740, #35742, #35744, #35749, #35750, #35751, #35756, #35766, #35768
- Failed merges:
@bors bors merged commit 2c3250a into rust-lang:master Aug 18, 2016
@nikomatsakis nikomatsakis added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Aug 18, 2016
@nikomatsakis
Copy link
Contributor

Accepting for beta: this was a serious correctness regression.

@brson brson removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Aug 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

drop not always behaving since nightly-2016-08-03-x86_64-unknown-linux-gnu
6 participants