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

Don't rerun MIR passes when inlining #55244

Merged
merged 4 commits into from
Oct 28, 2018
Merged

Conversation

wesleywiser
Copy link
Member

Fixes #50411

r? @nikomatsakis

I updated your commit message with additional details. Let me know if any of that is incorrect. I also added the appropriate compile-flags directive to the test.

Thanks for you help on this!

cc @RalfJung related to your PR #55086

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 21, 2018
@wesleywiser wesleywiser changed the title Issue 50411 Don't rerun MIR passes when inlining Oct 21, 2018
@rust-highfive

This comment has been minimized.

@@ -155,17 +155,30 @@ pub trait MirPass {
mir: &mut Mir<'tcx>);
}

pub macro run_passes($tcx:ident, $mir:ident, $def_id:ident, $suite_index:expr; $($pass:expr,)*) {{
let suite_index: usize = $suite_index;
pub macro run_passes(
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated: it'd be nice to move this out of a macro and into some kind of generic function. I don't really see any inherent difficulty in that. The functon could take a vec![&dyn MirPass] or else we could do some hancy h-list sort of thing (hint: seems unnecessary =)

nikomatsakis and others added 3 commits October 22, 2018 22:45
When inlining a function using the Mir inliner, we shouldn't rerun the
various Mir passes on it because the Mir has already been lowered and
that wil break various early Mir passes.

The issue in rust-lang#50411 is that we've inlined a function with promotions
whose Mir has already been lowered. The promotions are then copied into
the local function and we begin to run passes on their lowered Mir
which causes the ICE.

Fixes rust-lang#50411
This can be obtained via the `$mir_phase` value.
As suggested in the feedback for rust-lang#55244.

When I replaced the macro with a function, rustc started complaining
that there were two unused functions so I also removed those.
@wesleywiser
Copy link
Member Author

Good ideas! I've implemented the feedback.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

r=me

mir: &mut Mir<'tcx>,
def_id: DefId,
mir_phase: MirPhase,
passes: &[&dyn MirPass]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: rustfmt would put the ) { on the next line (with a trailing comma here)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah I was unsure of the convention here.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Oct 23, 2018

📌 Commit c535147 has been approved by nikomatsakis

@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 Oct 23, 2018
@wesleywiser
Copy link
Member Author

Is it worth getting a perf run on these changes? I'm unsure of what the impact might be. It's probably small though...

@wesleywiser
Copy link
Member Author

@bors try

For perf run, if we want that

@bors
Copy link
Contributor

bors commented Oct 23, 2018

🙅 Please do not try after a pull request has been r+ed. If you need to try, unapprove (r-) it first.

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Oct 24, 2018

@wesleywiser it is not worth it, in my opinion =)

/// Gets the index of the current MirPhase within the set of all MirPhases.
pub fn phase_index(&self) -> usize {
match self {
MirPhase::Build => 0,
Copy link
Member

Choose a reason for hiding this comment

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

Could you use self as usize instead of matching?

Copy link
Member

Choose a reason for hiding this comment

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

But then please assign the discriminants explicitly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I can change that.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Oct 25, 2018

📌 Commit 4655866 has been approved by nikomatsakis

pietroalbini added a commit to pietroalbini/rust that referenced this pull request Oct 25, 2018
…akis

Don't rerun MIR passes when inlining

Fixes rust-lang#50411

r? @nikomatsakis

I updated your commit message with additional details. Let me know if any of that is incorrect. I also added the appropriate `compile-flags` directive to the test.

Thanks for you help on this!

cc @RalfJung related to your PR rust-lang#55086
kennytm added a commit to kennytm/rust that referenced this pull request Oct 28, 2018
…akis

Don't rerun MIR passes when inlining

Fixes rust-lang#50411

r? @nikomatsakis

I updated your commit message with additional details. Let me know if any of that is incorrect. I also added the appropriate `compile-flags` directive to the test.

Thanks for you help on this!

cc @RalfJung related to your PR rust-lang#55086
bors added a commit that referenced this pull request Oct 28, 2018
Rollup of 11 pull requests

Successful merges:

 - #55148 (Implement FromStr for PathBuf)
 - #55185 (path suggestions in Rust 2018 should point out the change in semantics)
 - #55191 (Fix sub-variant doc display)
 - #55199 (Impl items have generics)
 - #55244 (Don't rerun MIR passes when inlining)
 - #55252 (Add MaybeUninit::new)
 - #55257 (Allow extern statics with an extern type)
 - #55389 (Remove unnecessary mut in iterator.find_map documentation example, R…)
 - #55406 (Update string.rs)
 - #55412 (Fix an ICE in the min_const_fn analysis)
 - #55421 (Add ManuallyDrop::take)
@bors bors merged commit 4655866 into rust-lang:master Oct 28, 2018
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants