Skip to content

Commit 4e253c2

Browse files
committed
INSTR_COST=2.
1 parent 861cda9 commit 4e253c2

8 files changed

+316
-2597
lines changed

compiler/rustc_mir_transform/src/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::ops::{Range, RangeFrom};
2222

2323
pub(crate) mod cycle;
2424

25-
const INSTR_COST: usize = 1;
25+
const INSTR_COST: usize = 2;
2626
const CALL_PENALTY: usize = 25;
2727
const LANDINGPAD_PENALTY: usize = 50;
2828
const RESUME_PENALTY: usize = 45;

tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff

+1-691
Large diffs are not rendered by default.

tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff

+12-110
Original file line numberDiff line numberDiff line change
@@ -12,59 +12,12 @@
1212
+ scope 3 (inlined std::ptr::drop_in_place::<Vec<A>> - shim(Some(Vec<A>))) {
1313
+ let mut _6: &mut std::vec::Vec<A>;
1414
+ let mut _7: ();
15-
+ scope 4 (inlined <Vec<A> as Drop>::drop) {
16-
+ debug self => _6;
17-
+ let mut _8: *mut [A];
18-
+ let mut _9: *mut A;
19-
+ let mut _10: usize;
20-
+ scope 5 {
21-
+ scope 6 (inlined Vec::<A>::as_mut_ptr) {
22-
+ debug self => _6;
23-
+ let mut _11: &alloc::raw_vec::RawVec<A>;
24-
+ scope 7 (inlined alloc::raw_vec::RawVec::<A>::ptr) {
25-
+ debug self => _11;
26-
+ let mut _13: std::ptr::NonNull<A>;
27-
+ scope 8 (inlined Unique::<A>::as_ptr) {
28-
+ debug ((self: Unique<A>).0: std::ptr::NonNull<A>) => _13;
29-
+ debug ((self: Unique<A>).1: std::marker::PhantomData<A>) => const ZeroSized: PhantomData<A>;
30-
+ scope 9 (inlined NonNull::<A>::as_ptr) {
31-
+ debug self => _13;
32-
+ let mut _12: *const A;
33-
+ }
34-
+ }
35-
+ }
36-
+ }
37-
+ scope 10 (inlined slice_from_raw_parts_mut::<A>) {
38-
+ debug data => _9;
39-
+ debug len => _10;
40-
+ let mut _14: *mut ();
41-
+ scope 11 (inlined ptr::mut_ptr::<impl *mut A>::cast::<()>) {
42-
+ debug self => _9;
43-
+ }
44-
+ scope 12 (inlined std::ptr::from_raw_parts_mut::<[A]>) {
45-
+ debug data_address => _14;
46-
+ debug metadata => _10;
47-
+ let mut _15: std::ptr::metadata::PtrRepr<[A]>;
48-
+ let mut _16: std::ptr::metadata::PtrComponents<[A]>;
49-
+ let mut _17: *const ();
50-
+ scope 13 {
51-
+ }
52-
+ }
53-
+ }
54-
+ scope 14 (inlined std::ptr::drop_in_place::<[A]> - shim(Some([A]))) {
55-
+ let mut _18: usize;
56-
+ let mut _19: usize;
57-
+ let mut _20: *mut A;
58-
+ let mut _21: bool;
59-
+ }
60-
+ }
61-
+ }
6215
+ }
6316
}
6417
scope 2 {
65-
+ scope 15 (inlined std::ptr::drop_in_place::<Option<B>> - shim(Some(Option<B>))) {
66-
+ let mut _22: isize;
67-
+ let mut _23: isize;
18+
+ scope 4 (inlined std::ptr::drop_in_place::<Option<B>> - shim(Some(Option<B>))) {
19+
+ let mut _8: isize;
20+
+ let mut _9: isize;
6821
+ }
6922
}
7023

@@ -76,42 +29,7 @@
7629
+ StorageLive(_6);
7730
+ StorageLive(_7);
7831
+ _6 = &mut (*_4);
79-
+ StorageLive(_8);
80-
+ StorageLive(_9);
81-
+ StorageLive(_11);
82-
+ _11 = &((*_6).0: alloc::raw_vec::RawVec<A>);
83-
+ StorageLive(_13);
84-
+ _13 = ((((*_6).0: alloc::raw_vec::RawVec<A>).0: std::ptr::Unique<A>).0: std::ptr::NonNull<A>);
85-
+ StorageLive(_12);
86-
+ _12 = (_13.0: *const A);
87-
+ _9 = move _12 as *mut A (PtrToPtr);
88-
+ StorageDead(_12);
89-
+ StorageDead(_13);
90-
+ StorageDead(_11);
91-
+ StorageLive(_10);
92-
+ _10 = ((*_6).1: usize);
93-
+ StorageLive(_14);
94-
+ _14 = _9 as *mut () (PtrToPtr);
95-
+ StorageLive(_15);
96-
+ StorageLive(_16);
97-
+ StorageLive(_17);
98-
+ _17 = _14 as *const () (PointerCoercion(MutToConstPointer));
99-
+ _16 = ptr::metadata::PtrComponents::<[A]> { data_address: move _17, metadata: _10 };
100-
+ StorageDead(_17);
101-
+ _15 = ptr::metadata::PtrRepr::<[A]> { const_ptr: move _16 };
102-
+ StorageDead(_16);
103-
+ _8 = (_15.1: *mut [A]);
104-
+ StorageDead(_15);
105-
+ StorageDead(_14);
106-
+ StorageDead(_10);
107-
+ StorageDead(_9);
108-
+ StorageLive(_18);
109-
+ StorageLive(_19);
110-
+ StorageLive(_20);
111-
+ StorageLive(_21);
112-
+ _18 = Len((*_8));
113-
+ _19 = const 0_usize;
114-
+ goto -> bb4;
32+
+ _7 = <Vec<A> as Drop>::drop(move _6) -> [return: bb2, unwind unreachable];
11533
}
11634

11735
bb1: {
@@ -122,41 +40,25 @@
12240
StorageLive(_5);
12341
_5 = _2;
12442
- _0 = std::ptr::drop_in_place::<Option<B>>(move _5) -> [return: bb2, unwind unreachable];
125-
+ StorageLive(_22);
126-
+ StorageLive(_23);
127-
+ _22 = discriminant((*_5));
128-
+ switchInt(move _22) -> [0: bb5, otherwise: bb6];
43+
+ StorageLive(_8);
44+
+ StorageLive(_9);
45+
+ _8 = discriminant((*_5));
46+
+ switchInt(move _8) -> [0: bb3, otherwise: bb4];
12947
}
13048

13149
bb2: {
132-
+ StorageDead(_21);
133-
+ StorageDead(_20);
134-
+ StorageDead(_19);
135-
+ StorageDead(_18);
136-
+ StorageDead(_8);
13750
+ drop(((*_4).0: alloc::raw_vec::RawVec<A>)) -> [return: bb1, unwind unreachable];
13851
+ }
13952
+
14053
+ bb3: {
141-
+ _20 = &raw mut (*_8)[_19];
142-
+ _19 = Add(move _19, const 1_usize);
143-
+ drop((*_20)) -> [return: bb4, unwind unreachable];
144-
+ }
145-
+
146-
+ bb4: {
147-
+ _21 = Eq(_19, _18);
148-
+ switchInt(move _21) -> [0: bb3, otherwise: bb2];
149-
+ }
150-
+
151-
+ bb5: {
152-
+ StorageDead(_23);
153-
+ StorageDead(_22);
54+
+ StorageDead(_9);
55+
+ StorageDead(_8);
15456
StorageDead(_5);
15557
return;
15658
+ }
15759
+
158-
+ bb6: {
159-
+ drop((((*_5) as Some).0: B)) -> [return: bb5, unwind unreachable];
60+
+ bb4: {
61+
+ drop((((*_5) as Some).0: B)) -> [return: bb3, unwind unreachable];
16062
}
16163
}
16264

0 commit comments

Comments
 (0)