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 inline virtual calls (take 2) #55802

Merged
merged 1 commit into from Nov 11, 2018

Conversation

Projects
None yet
6 participants
@wesleywiser
Member

wesleywiser commented Nov 9, 2018

When I fixed the previous mis-optimizations, I didn't realize there were
actually two different places where we mutate callsites and both of
them should have the same behavior.

As a result, if a function was inlined and that function contained
virtual function calls, they were incorrectly being inlined. I also
added a test case which covers this.

@rust-highfive

This comment has been minimized.

Collaborator

rust-highfive commented Nov 9, 2018

r? @michaelwoerister

(rust_highfive has picked a reviewer for you, use r? to override)

@michaelwoerister

This comment has been minimized.

Contributor

michaelwoerister commented Nov 9, 2018

Thanks for the PR, @wesleywiser!

@rust-lang/compiler, who is best suited for reviewing MIR inlining changes?

@oli-obk

Just some nits

substs) {
let is_virtual =
if let InstanceDef::Virtual(..) = instance.def {
true

This comment has been minimized.

@oli-obk

oli-obk Nov 9, 2018

Contributor

Since this is now its own function, you can get rid of is_virtual and just return None here.

let terminator = bb_data.terminator();
if let TerminatorKind::Call { func: ref op, .. } = terminator.kind {
if let ty::FnDef(callee_def_id, substs) = op.ty(caller_mir, self.tcx).sty {
if let Some(instance) = Instance::resolve(self.tcx,

This comment has been minimized.

@oli-obk

oli-obk Nov 9, 2018

Contributor

This can now just be let instance = Instance::resolve(....)?;

@bors

This comment has been minimized.

Contributor

bors commented Nov 9, 2018

☔️ The latest upstream changes (presumably #55803) made this pull request unmergeable. Please resolve the merge conflicts.

Don't inline virtual calls (take 2)
When I fixed the previous mis-optimizations, I didn't realize there were
actually two different places where we mutate `callsites` and both of
them should have the same behavior.

As a result, if a function was inlined and that function contained
virtual function calls, they were incorrectly being inlined. I also
added a test case which covers this.

@wesleywiser wesleywiser force-pushed the wesleywiser:inlined_calls_2_electric_boogaloo branch from f80b1a3 to 3cce5c7 Nov 10, 2018

@wesleywiser

This comment has been minimized.

Member

wesleywiser commented Nov 10, 2018

Good ideas @oli-obk!

@nagisa

This comment has been minimized.

Contributor

nagisa commented Nov 10, 2018

@bors r+

@bors

This comment has been minimized.

Contributor

bors commented Nov 10, 2018

📌 Commit 3cce5c7 has been approved by nagisa

pietroalbini added a commit to pietroalbini/rust that referenced this pull request Nov 10, 2018

Rollup merge of rust-lang#55802 - wesleywiser:inlined_calls_2_electri…
…c_boogaloo, r=nagisa

Don't inline virtual calls (take 2)

When I fixed the previous mis-optimizations, I didn't realize there were
actually two different places where we mutate `callsites` and both of
them should have the same behavior.

As a result, if a function was inlined and that function contained
virtual function calls, they were incorrectly being inlined. I also
added a test case which covers this.

bors added a commit that referenced this pull request Nov 10, 2018

Auto merge of #55854 - pietroalbini:rollup, r=pietroalbini
Rollup of 14 pull requests

Successful merges:

 - #55745 (Convert `outlives_components`' return value to a `SmallVec` outparam.)
 - #55764 (Fix Rc/Arc allocation layout)
 - #55792 (Prevent ICE in const-prop array oob check)
 - #55799 (Removed unneeded instance of `// revisions` from a lint test)
 - #55800 (Fix ICE in `return_type_impl_trait`)
 - #55801 (NLL: Update box insensitivity test)
 - #55802 (Don't inline virtual calls (take 2))
 - #55805 (Move `static_assert!` into librustc_data_structures)
 - #55816 (Use `SmallVec` to avoid allocations in `from_decimal_string`.)
 - #55819 (Typecheck patterns of all match arms first, so we get types for bindings)
 - #55822 (ICE with #![feature(nll)] and elided lifetimes)
 - #55828 (Add missing `rustc_promotable` attribute to unsigned `min_value` and `max_value`)
 - #55839 (Fix docstring spelling mistakes)
 - #55844 (Fix documentation typos.)

Failed merges:

r? @ghost

pietroalbini added a commit to pietroalbini/rust that referenced this pull request Nov 10, 2018

Rollup merge of rust-lang#55802 - wesleywiser:inlined_calls_2_electri…
…c_boogaloo, r=nagisa

Don't inline virtual calls (take 2)

When I fixed the previous mis-optimizations, I didn't realize there were
actually two different places where we mutate `callsites` and both of
them should have the same behavior.

As a result, if a function was inlined and that function contained
virtual function calls, they were incorrectly being inlined. I also
added a test case which covers this.

bors added a commit that referenced this pull request Nov 11, 2018

Auto merge of #55859 - pietroalbini:rollup, r=pietroalbini
Rollup of 14 pull requests

Successful merges:

 - #55687 (Take supertraits into account when calculating associated types)
 - #55745 (Convert `outlives_components`' return value to a `SmallVec` outparam.)
 - #55764 (Fix Rc/Arc allocation layout)
 - #55792 (Prevent ICE in const-prop array oob check)
 - #55799 (Removed unneeded instance of `// revisions` from a lint test)
 - #55800 (Fix ICE in `return_type_impl_trait`)
 - #55801 (NLL: Update box insensitivity test)
 - #55802 (Don't inline virtual calls (take 2))
 - #55816 (Use `SmallVec` to avoid allocations in `from_decimal_string`.)
 - #55819 (Typecheck patterns of all match arms first, so we get types for bindings)
 - #55822 (ICE with #![feature(nll)] and elided lifetimes)
 - #55828 (Add missing `rustc_promotable` attribute to unsigned `min_value` and `max_value`)
 - #55839 (Fix docstring spelling mistakes)
 - #55844 (Fix documentation typos.)

Failed merges:

r? @ghost

bors added a commit that referenced this pull request Nov 11, 2018

Auto merge of #55859 - pietroalbini:rollup, r=kennytm
Rollup of 17 pull requests

Successful merges:

 - #55630 (resolve: Filter away macro prelude in modules with `#[no_implicit_prelude]` on 2018 edition)
 - #55687 (Take supertraits into account when calculating associated types)
 - #55745 (Convert `outlives_components`' return value to a `SmallVec` outparam.)
 - #55764 (Fix Rc/Arc allocation layout)
 - #55792 (Prevent ICE in const-prop array oob check)
 - #55799 (Removed unneeded instance of `// revisions` from a lint test)
 - #55800 (Fix ICE in `return_type_impl_trait`)
 - #55801 (NLL: Update box insensitivity test)
 - #55802 (Don't inline virtual calls (take 2))
 - #55816 (Use `SmallVec` to avoid allocations in `from_decimal_string`.)
 - #55819 (Typecheck patterns of all match arms first, so we get types for bindings)
 - #55822 (ICE with #![feature(nll)] and elided lifetimes)
 - #55828 (Add missing `rustc_promotable` attribute to unsigned `min_value` and `max_value`)
 - #55839 (Fix docstring spelling mistakes)
 - #55844 (Fix documentation typos.)
 - #55845 (Set BINARYEN_TRAP_MODE=clamp)
 - #55856 (rustdoc: refactor: move all static-file include!s into a single module)

@bors bors merged commit 3cce5c7 into rust-lang:master Nov 11, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment