forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#78674 - tmiasko:inline-substs-for-mir-body,…
… r=oli-obk inliner: Use substs_for_mir_body Changes from 68965 extended the kind of instances that are being inlined. For some of those, the `instance_mir` returns a MIR body that is already expressed in terms of the types found in substitution array, and doesn't need further substitution. Use `substs_for_mir_body` to take that into account. Resolves rust-lang#78529. Resolves rust-lang#78560.
- Loading branch information
Showing
9 changed files
with
141 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#![crate_type = "lib"] | ||
|
||
// EMIT_MIR inline_shims.clone.Inline.diff | ||
pub fn clone<A, B>(f: fn(A, B)) -> fn(A, B) { | ||
f.clone() | ||
} | ||
|
||
// EMIT_MIR inline_shims.drop.Inline.diff | ||
pub fn drop<A, B>(a: *mut Vec<A>, b: *mut Option<B>) { | ||
unsafe { std::ptr::drop_in_place(a) } | ||
unsafe { std::ptr::drop_in_place(b) } | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
- // MIR for `clone` before Inline | ||
+ // MIR for `clone` after Inline | ||
|
||
fn clone(_1: fn(A, B)) -> fn(A, B) { | ||
debug f => _1; // in scope 0 at $DIR/inline-shims.rs:4:20: 4:21 | ||
let mut _0: fn(A, B); // return place in scope 0 at $DIR/inline-shims.rs:4:36: 4:44 | ||
let mut _2: &fn(A, B); // in scope 0 at $DIR/inline-shims.rs:5:5: 5:6 | ||
+ scope 1 (inlined <fn(A, B) as Clone>::clone - shim(fn(A, B))) { // at $DIR/inline-shims.rs:5:5: 5:14 | ||
+ } | ||
|
||
bb0: { | ||
StorageLive(_2); // scope 0 at $DIR/inline-shims.rs:5:5: 5:6 | ||
_2 = &_1; // scope 0 at $DIR/inline-shims.rs:5:5: 5:6 | ||
- _0 = <fn(A, B) as Clone>::clone(move _2) -> bb1; // scope 0 at $DIR/inline-shims.rs:5:5: 5:14 | ||
- // mir::Constant | ||
- // + span: $DIR/inline-shims.rs:5:7: 5:12 | ||
- // + literal: Const { ty: for<'r> fn(&'r fn(A, B)) -> fn(A, B) {<fn(A, B) as std::clone::Clone>::clone}, val: Value(Scalar(<ZST>)) } | ||
- } | ||
- | ||
- bb1: { | ||
+ _0 = (*_2); // scope 1 at $DIR/inline-shims.rs:5:5: 5:14 | ||
StorageDead(_2); // scope 0 at $DIR/inline-shims.rs:5:13: 5:14 | ||
return; // scope 0 at $DIR/inline-shims.rs:6:2: 6:2 | ||
} | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
- // MIR for `drop` before Inline | ||
+ // MIR for `drop` after Inline | ||
|
||
fn drop(_1: *mut Vec<A>, _2: *mut Option<B>) -> () { | ||
debug a => _1; // in scope 0 at $DIR/inline-shims.rs:9:19: 9:20 | ||
debug b => _2; // in scope 0 at $DIR/inline-shims.rs:9:35: 9:36 | ||
let mut _0: (); // return place in scope 0 at $DIR/inline-shims.rs:9:54: 9:54 | ||
let _3: (); // in scope 0 at $DIR/inline-shims.rs:10:14: 10:40 | ||
let mut _4: *mut std::vec::Vec<A>; // in scope 0 at $DIR/inline-shims.rs:10:38: 10:39 | ||
let mut _5: *mut std::option::Option<B>; // in scope 0 at $DIR/inline-shims.rs:11:38: 11:39 | ||
scope 1 { | ||
} | ||
scope 2 { | ||
+ scope 3 (inlined drop_in_place::<Option<B>> - shim(Some(Option<B>))) { // at $DIR/inline-shims.rs:11:14: 11:40 | ||
+ let mut _6: isize; // in scope 3 at $DIR/inline-shims.rs:11:14: 11:40 | ||
+ let mut _7: isize; // in scope 3 at $DIR/inline-shims.rs:11:14: 11:40 | ||
+ } | ||
} | ||
|
||
bb0: { | ||
StorageLive(_3); // scope 0 at $DIR/inline-shims.rs:10:5: 10:42 | ||
StorageLive(_4); // scope 1 at $DIR/inline-shims.rs:10:38: 10:39 | ||
_4 = _1; // scope 1 at $DIR/inline-shims.rs:10:38: 10:39 | ||
_3 = drop_in_place::<Vec<A>>(move _4) -> bb1; // scope 1 at $DIR/inline-shims.rs:10:14: 10:40 | ||
// mir::Constant | ||
// + span: $DIR/inline-shims.rs:10:14: 10:37 | ||
// + literal: Const { ty: unsafe fn(*mut std::vec::Vec<A>) {std::intrinsics::drop_in_place::<std::vec::Vec<A>>}, val: Value(Scalar(<ZST>)) } | ||
} | ||
|
||
bb1: { | ||
StorageDead(_4); // scope 1 at $DIR/inline-shims.rs:10:39: 10:40 | ||
StorageDead(_3); // scope 0 at $DIR/inline-shims.rs:10:41: 10:42 | ||
StorageLive(_5); // scope 2 at $DIR/inline-shims.rs:11:38: 11:39 | ||
_5 = _2; // scope 2 at $DIR/inline-shims.rs:11:38: 11:39 | ||
- _0 = drop_in_place::<Option<B>>(move _5) -> bb2; // scope 2 at $DIR/inline-shims.rs:11:14: 11:40 | ||
- // mir::Constant | ||
- // + span: $DIR/inline-shims.rs:11:14: 11:37 | ||
- // + literal: Const { ty: unsafe fn(*mut std::option::Option<B>) {std::intrinsics::drop_in_place::<std::option::Option<B>>}, val: Value(Scalar(<ZST>)) } | ||
+ _6 = discriminant((*_5)); // scope 3 at $DIR/inline-shims.rs:11:14: 11:40 | ||
+ switchInt(move _6) -> [0_isize: bb2, otherwise: bb3]; // scope 3 at $DIR/inline-shims.rs:11:14: 11:40 | ||
} | ||
|
||
bb2: { | ||
StorageDead(_5); // scope 2 at $DIR/inline-shims.rs:11:39: 11:40 | ||
return; // scope 0 at $DIR/inline-shims.rs:12:2: 12:2 | ||
+ } | ||
+ | ||
+ bb3: { | ||
+ drop((((*_5) as Some).0: B)) -> bb2; // scope 3 at $DIR/inline-shims.rs:11:14: 11:40 | ||
} | ||
} | ||
|