Skip to content

Commit 42cf29c

Browse files
committed
StripDebugInfo can be disabled by #[optimize(none)]
1 parent d2f335d commit 42cf29c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

compiler/rustc_mir_transform/src/strip_debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ impl<'tcx> crate::MirPass<'tcx> for StripDebugInfo {
3333
}
3434

3535
fn is_required(&self) -> bool {
36-
true
36+
false
3737
}
3838
}

tests/codegen/optimize-attr-1.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
//@ revisions: NO-OPT SIZE-OPT SPEED-OPT
1+
//@ revisions: NO-OPT DEBUGINFO SIZE-OPT SPEED-OPT
22
//@[NO-OPT] compile-flags: -Copt-level=0 -Ccodegen-units=1
3+
//@[DEBUGINFO] compile-flags: -Copt-level=1 -Ccodegen-units=1 -Cdebuginfo=full -Zmir_strip_debuginfo=all-locals
34
//@[SIZE-OPT] compile-flags: -Copt-level=s -Ccodegen-units=1
45
//@[SPEED-OPT] compile-flags: -Copt-level=3 -Ccodegen-units=1
56

@@ -27,6 +28,7 @@ pub fn size() -> i32 {
2728

2829
// CHECK-LABEL: define{{.*}}i32 @speed
2930
// NO-OPT-SAME: [[NOTHING_ATTRS]]
31+
// DEBUGINFO-SAME: [[NOTHING_ATTRS]]
3032
// SPEED-OPT-SAME: [[NOTHING_ATTRS]]
3133
// SIZE-OPT-SAME: [[SPEED_ATTRS:#[0-9]+]]
3234
// SIZE-OPT: ret i32 8
@@ -41,14 +43,16 @@ pub fn speed() -> i32 {
4143
// CHECK-SAME: [[NONE_ATTRS:#[0-9]+]]
4244
// SIZE-OPT: alloca
4345
// SPEED-OPT: alloca
46+
// DEBUGINFO-DAG: !DILocalVariable(name: "some_local_variable"
4447
#[no_mangle]
4548
#[optimize(none)]
4649
pub fn none() -> i32 {
47-
let arr = [0, 1, 2, 3, 4];
48-
arr[4]
50+
let some_local_variable = [0, 1, 2, 3, 4];
51+
some_local_variable[4]
4952
}
5053

5154
// NO-OPT-DAG: attributes [[SIZE_ATTRS]] = {{.*}}minsize{{.*}}optsize{{.*}}
55+
// DEBUGINFO-DAG: attributes [[SIZE_ATTRS]] = {{.*}}minsize{{.*}}optsize{{.*}}
5256
// SPEED-OPT-DAG: attributes [[SIZE_ATTRS]] = {{.*}}minsize{{.*}}optsize{{.*}}
5357
// SIZE-OPT-DAG: attributes [[NOTHING_ATTRS]] = {{.*}}optsize{{.*}}
5458
// SIZE-OPT-DAG: attributes [[SIZE_ATTRS]] = {{.*}}minsize{{.*}}optsize{{.*}}

0 commit comments

Comments
 (0)