Skip to content

Commit 8611e52

Browse files
committed
Auto merge of #74837 - xldenis:mir-dump-crate-file, r=oli-obk
Fix #70767 This PR changes the format of MIR dump filenames to include the crate name rather than `rustc` at the start. As a result, we can now place mir-opt tests in the same directory as the source files, like with UI tests. I had to make sure that `compiletest` added a bit_width suffix to the expected files when appropriate but otherwise the change is only moving the files to the correct location and ensuring that the `EMIT_MIR` lines are correct. Fixes #70767 cc @oli-obk
2 parents 6fd4c3f + f07607f commit 8611e52

File tree

306 files changed

+225
-422
lines changed

Some content is hidden

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

306 files changed

+225
-422
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ dependencies = [
611611
"diff",
612612
"env_logger 0.7.1",
613613
"getopts",
614+
"glob",
614615
"lazy_static",
615616
"libc",
616617
"log",

src/librustc_mir/util/pretty.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ fn dump_path(
177177
let mut file_path = PathBuf::new();
178178
file_path.push(Path::new(&tcx.sess.opts.debugging_opts.dump_mir_dir));
179179

180+
let crate_name = tcx.crate_name(source.def_id().krate);
180181
let item_name = tcx.def_path(source.def_id()).to_filename_friendly_no_crate();
181182
// All drop shims have the same DefId, so we have to add the type
182183
// to get unique file names.
@@ -196,8 +197,15 @@ fn dump_path(
196197
};
197198

198199
let file_name = format!(
199-
"rustc.{}{}{}{}.{}.{}.{}",
200-
item_name, shim_disambiguator, promotion_id, pass_num, pass_name, disambiguator, extension,
200+
"{}.{}{}{}{}.{}.{}.{}",
201+
crate_name,
202+
item_name,
203+
shim_disambiguator,
204+
promotion_id,
205+
pass_num,
206+
pass_name,
207+
disambiguator,
208+
extension,
201209
);
202210

203211
file_path.push(&file_name);

src/test/mir-opt/address-of.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// EMIT_MIR rustc.address_of_reborrow.SimplifyCfg-initial.after.mir
1+
// EMIT_MIR address_of.address_of_reborrow.SimplifyCfg-initial.after.mir
22

33
fn address_of_reborrow() {
44
let y = &[0; 10];
@@ -37,7 +37,7 @@ fn address_of_reborrow() {
3737
}
3838

3939
// The normal borrows here should be preserved
40-
// EMIT_MIR rustc.borrow_and_cast.SimplifyCfg-initial.after.mir
40+
// EMIT_MIR address_of.borrow_and_cast.SimplifyCfg-initial.after.mir
4141
fn borrow_and_cast(mut x: i32) {
4242
let p = &x as *const i32;
4343
let q = &mut x as *const i32;

src/test/mir-opt/array-index-is-temporary.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ unsafe fn foo(z: *mut usize) -> u32 {
88
}
99

1010
// EMIT_MIR_FOR_EACH_BIT_WIDTH
11-
// EMIT_MIR rustc.main.SimplifyCfg-elaborate-drops.after.mir
11+
// EMIT_MIR array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir
1212
fn main() {
1313
let mut x = [42, 43, 44];
1414
let mut y = 1;

src/test/mir-opt/basic_assignment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// this tests move up progration, which is not yet implemented
22

3-
// EMIT_MIR rustc.main.SimplifyCfg-initial.after.mir
3+
// EMIT_MIR basic_assignment.main.SimplifyCfg-initial.after.mir
44

55
// Check codegen for assignments (`a = b`) where the left-hand-side is
66
// not yet initialized. Assignments tend to be absent in simple code,

src/test/mir-opt/box_expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#![feature(box_syntax)]
44

5-
// EMIT_MIR rustc.main.ElaborateDrops.before.mir
5+
// EMIT_MIR box_expr.main.ElaborateDrops.before.mir
66
fn main() {
77
let x = box S::new();
88
drop(x);

src/test/mir-opt/byte_slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -Z mir-opt-level=0
22

3-
// EMIT_MIR rustc.main.SimplifyCfg-elaborate-drops.after.mir
3+
// EMIT_MIR byte_slice.main.SimplifyCfg-elaborate-drops.after.mir
44
fn main() {
55
let x = b"foo";
66
let y = [5u8, b'x'];

src/test/mir-opt/combine_array_len.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// EMIT_MIR_FOR_EACH_BIT_WIDTH
2-
// EMIT_MIR rustc.norm2.InstCombine.diff
2+
// EMIT_MIR combine_array_len.norm2.InstCombine.diff
33

44
fn norm2(x: [f32; 2]) -> f32 {
55
let a = x[0];

src/test/mir-opt/const-promotion-extern-static.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ extern "C" {
44

55
static Y: i32 = 42;
66

7-
// EMIT_MIR rustc.BAR.PromoteTemps.diff
8-
// EMIT_MIR rustc.BAR-promoted[0].ConstProp.after.mir
7+
// EMIT_MIR const_promotion_extern_static.BAR.PromoteTemps.diff
8+
// EMIT_MIR const_promotion_extern_static.BAR-promoted[0].ConstProp.after.mir
99
static mut BAR: *const &i32 = [&Y].as_ptr();
1010

11-
// EMIT_MIR rustc.FOO.PromoteTemps.diff
12-
// EMIT_MIR rustc.FOO-promoted[0].ConstProp.after.mir
11+
// EMIT_MIR const_promotion_extern_static.FOO.PromoteTemps.diff
12+
// EMIT_MIR const_promotion_extern_static.FOO-promoted[0].ConstProp.after.mir
1313
static mut FOO: *const &i32 = [unsafe { &X }].as_ptr();
1414

1515
fn main() {}

src/test/mir-opt/const_allocation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
static FOO: &[(Option<i32>, &[&str])] =
44
&[(None, &[]), (None, &["foo", "bar"]), (Some(42), &["meh", "mop", "möp"])];
55

6-
// EMIT_MIR rustc.main.ConstProp.after.mir
6+
// EMIT_MIR const_allocation.main.ConstProp.after.mir
77
fn main() {
88
FOO;
99
}

src/test/mir-opt/const_allocation2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// EMIT_MIR_FOR_EACH_BIT_WIDTH
22

3-
// EMIT_MIR rustc.main.ConstProp.after.mir
3+
// EMIT_MIR const_allocation2.main.ConstProp.after.mir
44
fn main() {
55
FOO;
66
}

src/test/mir-opt/const_allocation3.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// EMIT_MIR_FOR_EACH_BIT_WIDTH
22

3-
// EMIT_MIR rustc.main.ConstProp.after.mir
3+
// EMIT_MIR const_allocation3.main.ConstProp.after.mir
44
fn main() {
55
FOO;
66
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -O
22

3-
// EMIT_MIR rustc.main.ConstProp.diff
3+
// EMIT_MIR aggregate.main.ConstProp.diff
44
fn main() {
55
let x = (0, 1, 2).1 + 0;
66
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// EMIT_MIR_FOR_EACH_BIT_WIDTH
22

3-
// EMIT_MIR rustc.main.ConstProp.diff
3+
// EMIT_MIR array_index.main.ConstProp.diff
44
fn main() {
55
let x: u32 = [0, 1, 2, 3][2];
66
}

src/test/mir-opt/const_prop/bad_op_div_by_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// EMIT_MIR rustc.main.ConstProp.diff
1+
// EMIT_MIR bad_op_div_by_zero.main.ConstProp.diff
22
#[allow(unconditional_panic)]
33
fn main() {
44
let y = 0;

src/test/mir-opt/const_prop/bad_op_mod_by_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// EMIT_MIR rustc.main.ConstProp.diff
1+
// EMIT_MIR bad_op_mod_by_zero.main.ConstProp.diff
22
#[allow(unconditional_panic)]
33
fn main() {
44
let y = 0;

src/test/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// EMIT_MIR_FOR_EACH_BIT_WIDTH
2-
// EMIT_MIR rustc.main.ConstProp.diff
2+
// EMIT_MIR bad_op_unsafe_oob_for_slices.main.ConstProp.diff
33
#[allow(unconditional_panic)]
44
fn main() {
55
let a: *const [_] = &[1, 2, 3];

src/test/mir-opt/const_prop/boolean_identities.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -O -Zmir-opt-level=3
22

3-
// EMIT_MIR rustc.test.ConstProp.diff
3+
// EMIT_MIR boolean_identities.test.ConstProp.diff
44
pub fn test(x: bool, y: bool) -> bool {
55
(y | true) & (x & false)
66
}

src/test/mir-opt/const_prop/boxes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
// Note: this test verifies that we, in fact, do not const prop `box`
99

10-
// EMIT_MIR rustc.main.ConstProp.diff
10+
// EMIT_MIR boxes.main.ConstProp.diff
1111
fn main() {
1212
let x = *(box 42) + 0;
1313
}

src/test/mir-opt/const_prop/cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// EMIT_MIR rustc.main.ConstProp.diff
1+
// EMIT_MIR cast.main.ConstProp.diff
22

33
fn main() {
44
let x = 42u8 as u32;
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -C overflow-checks=on
22

3-
// EMIT_MIR rustc.main.ConstProp.diff
3+
// EMIT_MIR checked_add.main.ConstProp.diff
44
fn main() {
55
let x: u32 = 1 + 1;
66
}

src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[inline(never)]
22
fn read(_: usize) { }
33

4-
// EMIT_MIR rustc.main.ConstProp.diff
4+
// EMIT_MIR const_prop_fails_gracefully.main.ConstProp.diff
55
fn main() {
66
const FOO: &i32 = &1;
77
let x = FOO as *const i32 as usize;

src/test/mir-opt/const_prop/control-flow-simplification.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ trait NeedsDrop:Sized{
66

77
impl<This> NeedsDrop for This{}
88

9-
// EMIT_MIR rustc.hello.ConstProp.diff
10-
// EMIT_MIR rustc.hello.PreCodegen.before.mir
9+
// EMIT_MIR control_flow_simplification.hello.ConstProp.diff
10+
// EMIT_MIR control_flow_simplification.hello.PreCodegen.before.mir
1111
fn hello<T>(){
1212
if <bool>::NEEDS {
1313
panic!()

src/test/mir-opt/const_prop/discriminant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Fixing either of those will allow us to const-prop this away.
77

88
// EMIT_MIR_FOR_EACH_BIT_WIDTH
9-
// EMIT_MIR rustc.main.ConstProp.diff
9+
// EMIT_MIR discriminant.main.ConstProp.diff
1010
fn main() {
1111
let x = (if let Some(true) = Some(true) { 42 } else { 10 }) + 0;
1212
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -C overflow-checks=on
22

3-
// EMIT_MIR rustc.main.ConstProp.diff
3+
// EMIT_MIR indirect.main.ConstProp.diff
44
fn main() {
55
let x = (2u32 as u8) + 1;
66
}

src/test/mir-opt/const_prop/issue-66971.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn encode(this: ((), u8, u8)) {
1111
assert!(this.2 == 0);
1212
}
1313

14-
// EMIT_MIR rustc.main.ConstProp.diff
14+
// EMIT_MIR issue_66971.main.ConstProp.diff
1515
fn main() {
1616
encode(((), 0, 0));
1717
}

src/test/mir-opt/const_prop/issue-67019.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn test(this: ((u8, u8),)) {
66
assert!((this.0).0 == 1);
77
}
88

9-
// EMIT_MIR rustc.main.ConstProp.diff
9+
// EMIT_MIR issue_67019.main.ConstProp.diff
1010
fn main() {
1111
test(((1, 2),));
1212
}

src/test/mir-opt/const_prop/mult_by_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -O -Zmir-opt-level=3
22

3-
// EMIT_MIR rustc.test.ConstProp.diff
3+
// EMIT_MIR mult_by_zero.test.ConstProp.diff
44
fn test(x : i32) -> i32 {
55
x * 0
66
}

src/test/mir-opt/const_prop/mutable_variable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -O
22

3-
// EMIT_MIR rustc.main.ConstProp.diff
3+
// EMIT_MIR mutable_variable.main.ConstProp.diff
44
fn main() {
55
let mut x = 42;
66
x = 99;

src/test/mir-opt/const_prop/mutable_variable_aggregate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -O
22

3-
// EMIT_MIR rustc.main.ConstProp.diff
3+
// EMIT_MIR mutable_variable_aggregate.main.ConstProp.diff
44
fn main() {
55
let mut x = (42, 43);
66
x.1 = 99;

src/test/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -O
22

3-
// EMIT_MIR rustc.main.ConstProp.diff
3+
// EMIT_MIR mutable_variable_aggregate_mut_ref.main.ConstProp.diff
44
fn main() {
55
let mut x = (42, 43);
66
let z = &mut x;

src/test/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -O
22

3-
// EMIT_MIR rustc.main.ConstProp.diff
3+
// EMIT_MIR mutable_variable_aggregate_partial_read.main.ConstProp.diff
44
fn main() {
55
let mut x: (i32, i32) = foo();
66
x.1 = 99;

src/test/mir-opt/const_prop/mutable_variable_no_prop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
static mut STATIC: u32 = 42;
44

5-
// EMIT_MIR rustc.main.ConstProp.diff
5+
// EMIT_MIR mutable_variable_no_prop.main.ConstProp.diff
66
fn main() {
77
let mut x = 42;
88
unsafe {

src/test/mir-opt/const_prop/mutable_variable_unprop_assign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -O
22

3-
// EMIT_MIR rustc.main.ConstProp.diff
3+
// EMIT_MIR mutable_variable_unprop_assign.main.ConstProp.diff
44
fn main() {
55
let a = foo();
66
let mut x: (i32, i32) = (1, 2);

src/test/mir-opt/const_prop/optimizes_into_variable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ struct Point {
66
}
77

88
// EMIT_MIR_FOR_EACH_BIT_WIDTH
9-
// EMIT_MIR rustc.main.ConstProp.diff
10-
// EMIT_MIR rustc.main.SimplifyLocals.after.mir
9+
// EMIT_MIR optimizes_into_variable.main.ConstProp.diff
10+
// EMIT_MIR optimizes_into_variable.main.SimplifyLocals.after.mir
1111
fn main() {
1212
let x = 2 + 2;
1313
let y = [0, 1, 2, 3, 4, 5][3];

src/test/mir-opt/const_prop/read_immutable_static.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
static FOO: u8 = 2;
44

5-
// EMIT_MIR rustc.main.ConstProp.diff
5+
// EMIT_MIR read_immutable_static.main.ConstProp.diff
66
fn main() {
77
let x = FOO + FOO;
88
}

src/test/mir-opt/const_prop/ref_deref.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// EMIT_MIR rustc.main.PromoteTemps.diff
2-
// EMIT_MIR rustc.main.ConstProp.diff
1+
// EMIT_MIR ref_deref.main.PromoteTemps.diff
2+
// EMIT_MIR ref_deref.main.ConstProp.diff
33

44
fn main() {
55
*(&4);

src/test/mir-opt/const_prop/ref_deref_project.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// EMIT_MIR rustc.main.PromoteTemps.diff
2-
// EMIT_MIR rustc.main.ConstProp.diff
1+
// EMIT_MIR ref_deref_project.main.PromoteTemps.diff
2+
// EMIT_MIR ref_deref_project.main.ConstProp.diff
33

44
fn main() {
55
*(&(4, 5).1); // This does not currently propagate (#67862)

src/test/mir-opt/const_prop/reify_fn_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// EMIT_MIR rustc.main.ConstProp.diff
1+
// EMIT_MIR reify_fn_ptr.main.ConstProp.diff
22

33
fn main() {
44
let _ = main as usize as *const fn();

src/test/mir-opt/const_prop/repeat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// compile-flags: -O
22

33
// EMIT_MIR_FOR_EACH_BIT_WIDTH
4-
// EMIT_MIR rustc.main.ConstProp.diff
4+
// EMIT_MIR repeat.main.ConstProp.diff
55
fn main() {
66
let x: u32 = [42; 8][2] + 0;
77
}

src/test/mir-opt/const_prop/return_place.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// compile-flags: -C overflow-checks=on
22

3-
// EMIT_MIR rustc.add.ConstProp.diff
4-
// EMIT_MIR rustc.add.PreCodegen.before.mir
3+
// EMIT_MIR return_place.add.ConstProp.diff
4+
// EMIT_MIR return_place.add.PreCodegen.before.mir
55
fn add() -> u32 {
66
2 + 2
77
}

src/test/mir-opt/const_prop/scalar_literal_propagation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// EMIT_MIR rustc.main.ConstProp.diff
1+
// EMIT_MIR scalar_literal_propagation.main.ConstProp.diff
22
fn main() {
33
let x = 1;
44
consume(x);
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// EMIT_MIR_FOR_EACH_BIT_WIDTH
22

3-
// EMIT_MIR rustc.main.ConstProp.diff
3+
// EMIT_MIR slice_len.main.ConstProp.diff
44
fn main() {
55
(&[1u32, 2, 3] as &[u32])[1];
66
}

src/test/mir-opt/const_prop/switch_int.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#[inline(never)]
22
fn foo(_: i32) { }
33

4-
// EMIT_MIR rustc.main.ConstProp.diff
5-
// EMIT_MIR rustc.main.SimplifyBranches-after-const-prop.diff
4+
// EMIT_MIR switch_int.main.ConstProp.diff
5+
// EMIT_MIR switch_int.main.SimplifyBranches-after-const-prop.diff
66
fn main() {
77
match 1 {
88
1 => foo(0),

0 commit comments

Comments
 (0)