Skip to content

Commit 8f9e4a5

Browse files
committed
At debuginfo=0, don't inline debuginfo when inlining
1 parent 0d8b334 commit 8f9e4a5

File tree

102 files changed

+771
-1177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+771
-1177
lines changed

compiler/rustc_mir_transform/src/inline.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_middle::mir::visit::*;
1111
use rustc_middle::mir::*;
1212
use rustc_middle::ty::TypeVisitableExt;
1313
use rustc_middle::ty::{self, Instance, InstanceDef, ParamEnv, Ty, TyCtxt};
14-
use rustc_session::config::OptLevel;
14+
use rustc_session::config::{DebugInfo, OptLevel};
1515
use rustc_span::source_map::Spanned;
1616
use rustc_span::sym;
1717
use rustc_target::abi::FieldIdx;
@@ -699,7 +699,9 @@ impl<'tcx> Inliner<'tcx> {
699699
// Insert all of the (mapped) parts of the callee body into the caller.
700700
caller_body.local_decls.extend(callee_body.drain_vars_and_temps());
701701
caller_body.source_scopes.extend(&mut callee_body.source_scopes.drain(..));
702-
caller_body.var_debug_info.append(&mut callee_body.var_debug_info);
702+
if self.tcx.sess.opts.debuginfo != DebugInfo::None {
703+
caller_body.var_debug_info.append(&mut callee_body.var_debug_info);
704+
}
703705
caller_body.basic_blocks_mut().extend(callee_body.basic_blocks_mut().drain(..));
704706

705707
caller_body[callsite.block].terminator = Some(Terminator {

tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
scope 1 {
1010
}
1111
scope 2 (inlined #[track_caller] <u8 as Add>::add) {
12-
debug self => _2;
13-
debug other => _3;
1412
let mut _4: (u8, bool);
1513
}
1614

tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
scope 1 {
1010
}
1111
scope 2 (inlined #[track_caller] <u8 as Add>::add) {
12-
debug self => _2;
13-
debug other => _3;
1412
let mut _4: (u8, bool);
1513
}
1614

tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@
1212
let _3: std::ptr::Unique<[bool]>;
1313
let mut _4: std::ptr::Unique<[bool; 0]>;
1414
scope 3 {
15-
debug ptr => _3;
1615
}
1716
scope 4 (inlined Unique::<[bool; 0]>::dangling) {
1817
let mut _5: std::ptr::NonNull<[bool; 0]>;
1918
scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
2019
let _6: *mut [bool; 0];
2120
scope 6 {
22-
debug ptr => _6;
2321
scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
24-
debug ptr => _6;
2522
let mut _8: bool;
2623
let _9: ();
2724
let mut _10: *mut ();
@@ -37,7 +34,6 @@
3734
scope 8 (inlined align_of::<[bool; 0]>) {
3835
}
3936
scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
40-
debug addr => _7;
4137
}
4238
}
4339
}

tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@
1212
let _3: std::ptr::Unique<[bool]>;
1313
let mut _4: std::ptr::Unique<[bool; 0]>;
1414
scope 3 {
15-
debug ptr => _3;
1615
}
1716
scope 4 (inlined Unique::<[bool; 0]>::dangling) {
1817
let mut _5: std::ptr::NonNull<[bool; 0]>;
1918
scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
2019
let _6: *mut [bool; 0];
2120
scope 6 {
22-
debug ptr => _6;
2321
scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
24-
debug ptr => _6;
2522
let mut _8: bool;
2623
let _9: ();
2724
let mut _10: *mut ();
@@ -37,7 +34,6 @@
3734
scope 8 (inlined align_of::<[bool; 0]>) {
3835
}
3936
scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
40-
debug addr => _7;
4137
}
4238
}
4339
}

tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@
1212
let _3: std::ptr::Unique<[bool]>;
1313
let mut _4: std::ptr::Unique<[bool; 0]>;
1414
scope 3 {
15-
debug ptr => _3;
1615
}
1716
scope 4 (inlined Unique::<[bool; 0]>::dangling) {
1817
let mut _5: std::ptr::NonNull<[bool; 0]>;
1918
scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
2019
let _6: *mut [bool; 0];
2120
scope 6 {
22-
debug ptr => _6;
2321
scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
24-
debug ptr => _6;
2522
let mut _8: bool;
2623
let _9: ();
2724
let mut _10: *mut ();
@@ -37,7 +34,6 @@
3734
scope 8 (inlined align_of::<[bool; 0]>) {
3835
}
3936
scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
40-
debug addr => _7;
4137
}
4238
}
4339
}

tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@
1212
let _3: std::ptr::Unique<[bool]>;
1313
let mut _4: std::ptr::Unique<[bool; 0]>;
1414
scope 3 {
15-
debug ptr => _3;
1615
}
1716
scope 4 (inlined Unique::<[bool; 0]>::dangling) {
1817
let mut _5: std::ptr::NonNull<[bool; 0]>;
1918
scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
2019
let _6: *mut [bool; 0];
2120
scope 6 {
22-
debug ptr => _6;
2321
scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
24-
debug ptr => _6;
2522
let mut _8: bool;
2623
let _9: ();
2724
let mut _10: *mut ();
@@ -37,7 +34,6 @@
3734
scope 8 (inlined align_of::<[bool; 0]>) {
3835
}
3936
scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
40-
debug addr => _7;
4137
}
4238
}
4339
}

tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@
1212
let _3: std::ptr::Unique<[bool]>;
1313
let mut _4: std::ptr::Unique<[bool; 0]>;
1414
scope 3 {
15-
debug ptr => _3;
1615
}
1716
scope 4 (inlined Unique::<[bool; 0]>::dangling) {
1817
let mut _5: std::ptr::NonNull<[bool; 0]>;
1918
scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
2019
let _6: *mut [bool; 0];
2120
scope 6 {
22-
debug ptr => _6;
2321
scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
24-
debug ptr => _6;
2522
let mut _8: bool;
2623
let _9: ();
2724
let mut _10: *mut ();
@@ -37,7 +34,6 @@
3734
scope 8 (inlined align_of::<[bool; 0]>) {
3835
}
3936
scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
40-
debug addr => _7;
4137
}
4238
}
4339
}

tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@
1212
let _3: std::ptr::Unique<[bool]>;
1313
let mut _4: std::ptr::Unique<[bool; 0]>;
1414
scope 3 {
15-
debug ptr => _3;
1615
}
1716
scope 4 (inlined Unique::<[bool; 0]>::dangling) {
1817
let mut _5: std::ptr::NonNull<[bool; 0]>;
1918
scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
2019
let _6: *mut [bool; 0];
2120
scope 6 {
22-
debug ptr => _6;
2321
scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
24-
debug ptr => _6;
2522
let mut _8: bool;
2623
let _9: ();
2724
let mut _10: *mut ();
@@ -37,7 +34,6 @@
3734
scope 8 (inlined align_of::<[bool; 0]>) {
3835
}
3936
scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
40-
debug addr => _7;
4137
}
4238
}
4339
}

tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@
1212
let _3: std::ptr::Unique<[bool]>;
1313
let mut _4: std::ptr::Unique<[bool; 0]>;
1414
scope 3 {
15-
debug ptr => _3;
1615
}
1716
scope 4 (inlined Unique::<[bool; 0]>::dangling) {
1817
let mut _5: std::ptr::NonNull<[bool; 0]>;
1918
scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
2019
let _6: *mut [bool; 0];
2120
scope 6 {
22-
debug ptr => _6;
2321
scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
24-
debug ptr => _6;
2522
let mut _8: bool;
2623
let _9: ();
2724
let mut _10: *mut ();
@@ -37,7 +34,6 @@
3734
scope 8 (inlined align_of::<[bool; 0]>) {
3835
}
3936
scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
40-
debug addr => _7;
4137
}
4238
}
4339
}

tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@
1212
let _3: std::ptr::Unique<[bool]>;
1313
let mut _4: std::ptr::Unique<[bool; 0]>;
1414
scope 3 {
15-
debug ptr => _3;
1615
}
1716
scope 4 (inlined Unique::<[bool; 0]>::dangling) {
1817
let mut _5: std::ptr::NonNull<[bool; 0]>;
1918
scope 5 (inlined NonNull::<[bool; 0]>::dangling) {
2019
let _6: *mut [bool; 0];
2120
scope 6 {
22-
debug ptr => _6;
2321
scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) {
24-
debug ptr => _6;
2522
let mut _8: bool;
2623
let _9: ();
2724
let mut _10: *mut ();
@@ -37,7 +34,6 @@
3734
scope 8 (inlined align_of::<[bool; 0]>) {
3835
}
3936
scope 9 (inlined without_provenance_mut::<[bool; 0]>) {
40-
debug addr => _7;
4137
}
4238
}
4339
}

tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
scope 1 {
1010
}
1111
scope 2 (inlined #[track_caller] <u8 as Add>::add) {
12-
debug self => _2;
13-
debug other => _3;
1412
let mut _4: (u8, bool);
1513
}
1614

tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
scope 1 {
1010
}
1111
scope 2 (inlined #[track_caller] <u8 as Add>::add) {
12-
debug self => _2;
13-
debug other => _3;
1412
let mut _4: (u8, bool);
1513
}
1614

tests/mir-opt/dest-prop/union.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// skip-filecheck
22
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
33
//! Tests that we can propagate into places that are projections into unions
4-
//@ compile-flags: -Zunsound-mir-opts
4+
//@ compile-flags: -Zunsound-mir-opts -C debuginfo=full
55
fn val() -> u32 {
66
1
77
}

tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@
2929
debug precision => _8;
3030
let _8: usize;
3131
scope 5 (inlined Formatter::<'_>::precision) {
32-
debug self => _1;
3332
}
3433
}
3534
}
3635
}
3736
scope 4 (inlined Formatter::<'_>::sign_plus) {
38-
debug self => _1;
3937
let mut _20: u32;
4038
let mut _21: u32;
4139
}

tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@
2929
debug precision => _8;
3030
let _8: usize;
3131
scope 5 (inlined Formatter::<'_>::precision) {
32-
debug self => _1;
3332
}
3433
}
3534
}
3635
}
3736
scope 4 (inlined Formatter::<'_>::sign_plus) {
38-
debug self => _1;
3937
let mut _20: u32;
4038
let mut _21: u32;
4139
}

tests/mir-opt/inline/asm_unwind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
44
//@ needs-asm-support
55
//@ needs-unwind
6-
//@ compile-flags: -Zinline-mir-hint-threshold=1000
6+
//@ compile-flags: -Zinline-mir-hint-threshold=1000 -C debuginfo=full
77
#![feature(asm_unwind)]
88

99
struct D;

tests/mir-opt/inline/cycle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
2-
//@ compile-flags: -Zinline-mir-hint-threshold=1000
2+
//@ compile-flags: -Zinline-mir-hint-threshold=1000 -C debuginfo=full
33

44
// EMIT_MIR cycle.f.Inline.diff
55
#[inline(always)]

tests/mir-opt/inline/dyn_trait.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
2+
//@ compile-flags: -C debuginfo=full
23
#![crate_type = "lib"]
34

45
use std::fmt::Debug;

tests/mir-opt/inline/inline_any_operand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Z span_free_formats
1+
//@ compile-flags: -Z span_free_formats -C debuginfo=full
22

33
// Tests that MIR inliner works for any operand
44

tests/mir-opt/inline/inline_closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Z span_free_formats
1+
//@ compile-flags: -Z span_free_formats -C debuginfo=full
22

33
// Tests that MIR inliner can handle closure arguments. (#45894)
44

tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ fn foo(_1: T, _2: &i32) -> i32 {
1414
scope 1 {
1515
debug x => _3;
1616
scope 2 (inlined foo::<T>::{closure#0}) {
17-
debug r => _8;
18-
debug _s => _9;
1917
scope 3 {
20-
debug variable => _8;
2118
}
2219
}
2320
}

tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ fn foo(_1: T, _2: i32) -> (i32, T) {
1414
scope 1 {
1515
debug x => _3;
1616
scope 2 (inlined foo::<T>::{closure#0}) {
17-
debug _q => _9;
18-
debug q => (*((*_6).0: &i32));
19-
debug t => (*((*_6).1: &T));
2017
let mut _10: &i32;
2118
let mut _11: i32;
2219
let mut _12: &T;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
+ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new) {
1717
+ debug pointer => _3;
1818
+ scope 4 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new_unchecked) {
19-
+ debug pointer => _3;
2019
+ }
2120
+ }
2221
+ scope 5 (inlined g::{closure#0}) {

tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
+ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new) {
1717
+ debug pointer => _3;
1818
+ scope 4 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new_unchecked) {
19-
+ debug pointer => _3;
2019
+ }
2120
+ }
2221
+ scope 5 (inlined g::{closure#0}) {

tests/mir-opt/inline/inline_coroutine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
2-
//@ compile-flags: -Zinline-mir-hint-threshold=1000
2+
//@ compile-flags: -Zinline-mir-hint-threshold=1000 -C debuginfo=full
33
#![feature(coroutines, coroutine_trait)]
44

55
use std::ops::Coroutine;

tests/mir-opt/inline/inline_cycle.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// skip-filecheck
2+
//@ compile-flags: -C debuginfo=full
23
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
34
// Check that inliner handles various forms of recursion and doesn't fall into
45
// an infinite inlining cycle. The particular outcome of inlining is not

tests/mir-opt/inline/inline_diverging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Tests inlining of diverging calls.
22
//
33
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
4-
//@ compile-flags: -Zinline-mir-hint-threshold=1000
4+
//@ compile-flags: -Zinline-mir-hint-threshold=1000 -C debuginfo=full
55
#![crate_type = "lib"]
66

77
// EMIT_MIR inline_diverging.f.Inline.diff

tests/mir-opt/inline/inline_retag.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Z span_free_formats -Z mir-emit-retag
1+
//@ compile-flags: -Z span_free_formats -Z mir-emit-retag -C debuginfo=full
22

33
// Tests that MIR inliner fixes up `Retag`'s `fn_entry` flag
44

tests/mir-opt/inline/inline_trait_method_2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
2-
//@ compile-flags: -Z span_free_formats -Z mir-opt-level=4
2+
//@ compile-flags: -Z span_free_formats -Z mir-opt-level=4 -C debuginfo=full
33

44
// EMIT_MIR inline_trait_method_2.test2.Inline.after.mir
55
fn test2(x: &dyn X) -> bool {

0 commit comments

Comments
 (0)