Skip to content

Commit 15c968a

Browse files
committed
inline: Drop debuginfos if drop var debuginfos
1 parent 774d83d commit 15c968a

11 files changed

+11
-42
lines changed

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,13 @@ impl<'tcx> BasicBlockData<'tcx> {
14301430
pub fn strip_nops(&mut self) {
14311431
self.retain_statements(|stmt| !matches!(stmt.kind, StatementKind::Nop))
14321432
}
1433+
1434+
pub fn drop_debuginfo(&mut self) {
1435+
self.after_last_stmt_debuginfos = Vec::new();
1436+
for stmt in self.statements.iter_mut() {
1437+
stmt.debuginfos = Vec::new();
1438+
}
1439+
}
14331440
}
14341441

14351442
///////////////////////////////////////////////////////////////////////////

compiler/rustc_mir_transform/src/inline.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,10 @@ fn inline_call<'tcx, I: Inliner<'tcx>>(
992992
// people working on rust can build with or without debuginfo while
993993
// still getting consistent results from the mir-opt tests.
994994
caller_body.var_debug_info.append(&mut callee_body.var_debug_info);
995+
} else {
996+
for bb in callee_body.basic_blocks_mut() {
997+
bb.drop_debuginfo();
998+
}
995999
}
9961000
caller_body.basic_blocks_mut().append(callee_body.basic_blocks_mut());
9971001

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@
6565
+ StorageLive(_12);
6666
+ StorageLive(_8);
6767
+ StorageLive(_9);
68-
+ // DBG: AssignRef(_11, ((*_6).0: alloc::raw_vec::RawVec<A>))
69-
+ // DBG: AssignRef(_12, (((*_6).0: alloc::raw_vec::RawVec<A>).0: alloc::raw_vec::RawVecInner))
7068
+ StorageLive(_13);
7169
+ _13 = copy (((((*_6).0: alloc::raw_vec::RawVec<A>).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique<u8>).0: std::ptr::NonNull<u8>);
7270
+ _9 = copy _13 as *mut A (Transmute);

tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,7 @@
233233
+ StorageLive(_50);
234234
+ StorageLive(_42);
235235
+ StorageLive(_43);
236-
+ // DBG: AssignRef(_46, _19)
237-
+ // DBG: AssignRef(_47, (_19.0: &mut std::future::Ready<()>))
238236
+ _45 = copy (_19.0: &mut std::future::Ready<()>);
239-
+ // DBG: AssignRef(_44, ((*_45).0: std::option::Option<()>))
240237
+ StorageLive(_48);
241238
+ _48 = Option::<()>::None;
242239
+ _43 = copy ((*_45).0: std::option::Option<()>);

tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,7 @@
250250
+ StorageLive(_52);
251251
+ StorageLive(_44);
252252
+ StorageLive(_45);
253-
+ // DBG: AssignRef(_48, _19)
254-
+ // DBG: AssignRef(_49, (_19.0: &mut std::future::Ready<()>))
255253
+ _47 = copy (_19.0: &mut std::future::Ready<()>);
256-
+ // DBG: AssignRef(_46, ((*_47).0: std::option::Option<()>))
257254
+ StorageLive(_50);
258255
+ _50 = Option::<()>::None;
259256
+ _45 = copy ((*_47).0: std::option::Option<()>);

tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.32bit.panic-abort.mir

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ fn num_to_digit(_1: char) -> u32 {
66
let mut _4: std::option::Option<u32>;
77
scope 1 (inlined char::methods::<impl char>::is_digit) {
88
let _2: std::option::Option<u32>;
9-
let mut _7: &std::option::Option<u32>;
109
scope 2 (inlined Option::<u32>::is_some) {
1110
let mut _3: isize;
1211
}
@@ -19,17 +18,14 @@ fn num_to_digit(_1: char) -> u32 {
1918
}
2019

2120
bb0: {
22-
StorageLive(_7);
2321
StorageLive(_2);
2422
_2 = char::methods::<impl char>::to_digit(copy _1, const 8_u32) -> [return: bb1, unwind unreachable];
2523
}
2624

2725
bb1: {
28-
// DBG: AssignRef(_7, _2)
2926
StorageLive(_3);
3027
_3 = discriminant(_2);
3128
StorageDead(_2);
32-
StorageDead(_7);
3329
switchInt(move _3) -> [1: bb2, otherwise: bb7];
3430
}
3531

tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.32bit.panic-unwind.mir

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ fn num_to_digit(_1: char) -> u32 {
66
let mut _4: std::option::Option<u32>;
77
scope 1 (inlined char::methods::<impl char>::is_digit) {
88
let _2: std::option::Option<u32>;
9-
let mut _7: &std::option::Option<u32>;
109
scope 2 (inlined Option::<u32>::is_some) {
1110
let mut _3: isize;
1211
}
@@ -19,17 +18,14 @@ fn num_to_digit(_1: char) -> u32 {
1918
}
2019

2120
bb0: {
22-
StorageLive(_7);
2321
StorageLive(_2);
2422
_2 = char::methods::<impl char>::to_digit(copy _1, const 8_u32) -> [return: bb1, unwind continue];
2523
}
2624

2725
bb1: {
28-
// DBG: AssignRef(_7, _2)
2926
StorageLive(_3);
3027
_3 = discriminant(_2);
3128
StorageDead(_2);
32-
StorageDead(_7);
3329
switchInt(move _3) -> [1: bb2, otherwise: bb7];
3430
}
3531

tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.64bit.panic-abort.mir

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ fn num_to_digit(_1: char) -> u32 {
66
let mut _4: std::option::Option<u32>;
77
scope 1 (inlined char::methods::<impl char>::is_digit) {
88
let _2: std::option::Option<u32>;
9-
let mut _7: &std::option::Option<u32>;
109
scope 2 (inlined Option::<u32>::is_some) {
1110
let mut _3: isize;
1211
}
@@ -19,17 +18,14 @@ fn num_to_digit(_1: char) -> u32 {
1918
}
2019

2120
bb0: {
22-
StorageLive(_7);
2321
StorageLive(_2);
2422
_2 = char::methods::<impl char>::to_digit(copy _1, const 8_u32) -> [return: bb1, unwind unreachable];
2523
}
2624

2725
bb1: {
28-
// DBG: AssignRef(_7, _2)
2926
StorageLive(_3);
3027
_3 = discriminant(_2);
3128
StorageDead(_2);
32-
StorageDead(_7);
3329
switchInt(move _3) -> [1: bb2, otherwise: bb7];
3430
}
3531

tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.64bit.panic-unwind.mir

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ fn num_to_digit(_1: char) -> u32 {
66
let mut _4: std::option::Option<u32>;
77
scope 1 (inlined char::methods::<impl char>::is_digit) {
88
let _2: std::option::Option<u32>;
9-
let mut _7: &std::option::Option<u32>;
109
scope 2 (inlined Option::<u32>::is_some) {
1110
let mut _3: isize;
1211
}
@@ -19,17 +18,14 @@ fn num_to_digit(_1: char) -> u32 {
1918
}
2019

2120
bb0: {
22-
StorageLive(_7);
2321
StorageLive(_2);
2422
_2 = char::methods::<impl char>::to_digit(copy _1, const 8_u32) -> [return: bb1, unwind continue];
2523
}
2624

2725
bb1: {
28-
// DBG: AssignRef(_7, _2)
2926
StorageLive(_3);
3027
_3 = discriminant(_2);
3128
StorageDead(_2);
32-
StorageDead(_7);
3329
switchInt(move _3) -> [1: bb2, otherwise: bb7];
3430
}
3531

tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
66
let mut _0: u16;
77
scope 1 (inlined <u16 as Step>::forward) {
88
let mut _8: u16;
9-
let mut _9: &std::option::Option<u16>;
10-
let _10: std::option::Option<u16>;
119
scope 2 {
1210
}
1311
scope 3 (inlined <u16 as Step>::forward_checked) {
@@ -34,8 +32,6 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
3432
}
3533

3634
bb0: {
37-
StorageLive(_9);
38-
StorageLive(_10);
3935
StorageLive(_4);
4036
StorageLive(_3);
4137
_3 = Gt(copy _2, const 65535_usize);
@@ -55,7 +51,6 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
5551
bb2: {
5652
StorageDead(_5);
5753
StorageDead(_6);
58-
// DBG: AssignRef(_9, _10)
5954
goto -> bb7;
6055
}
6156

@@ -66,13 +61,11 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
6661
bb4: {
6762
StorageDead(_5);
6863
StorageDead(_6);
69-
// DBG: AssignRef(_9, _10)
7064
goto -> bb6;
7165
}
7266

7367
bb5: {
7468
StorageDead(_3);
75-
// DBG: AssignRef(_9, _10)
7669
goto -> bb6;
7770
}
7871

@@ -86,8 +79,6 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
8679
_0 = Add(copy _1, copy _8);
8780
StorageDead(_8);
8881
StorageDead(_4);
89-
StorageDead(_10);
90-
StorageDead(_9);
9182
return;
9283
}
9384
}

tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
66
let mut _0: u16;
77
scope 1 (inlined <u16 as Step>::forward) {
88
let mut _8: u16;
9-
let mut _9: &std::option::Option<u16>;
10-
let _10: std::option::Option<u16>;
119
scope 2 {
1210
}
1311
scope 3 (inlined <u16 as Step>::forward_checked) {
@@ -34,8 +32,6 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
3432
}
3533

3634
bb0: {
37-
StorageLive(_9);
38-
StorageLive(_10);
3935
StorageLive(_4);
4036
StorageLive(_3);
4137
_3 = Gt(copy _2, const 65535_usize);
@@ -55,7 +51,6 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
5551
bb2: {
5652
StorageDead(_5);
5753
StorageDead(_6);
58-
// DBG: AssignRef(_9, _10)
5954
goto -> bb7;
6055
}
6156

@@ -66,13 +61,11 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
6661
bb4: {
6762
StorageDead(_5);
6863
StorageDead(_6);
69-
// DBG: AssignRef(_9, _10)
7064
goto -> bb6;
7165
}
7266

7367
bb5: {
7468
StorageDead(_3);
75-
// DBG: AssignRef(_9, _10)
7669
goto -> bb6;
7770
}
7871

@@ -86,8 +79,6 @@ fn step_forward(_1: u16, _2: usize) -> u16 {
8679
_0 = Add(copy _1, copy _8);
8780
StorageDead(_8);
8881
StorageDead(_4);
89-
StorageDead(_10);
90-
StorageDead(_9);
9182
return;
9283
}
9384
}

0 commit comments

Comments
 (0)