Skip to content

Commit 1edcfc8

Browse files
committed
Auto merge of #70721 - anyska:bless-all-mir-opt, r=oli-obk
--bless all mir-opt tests. r? @oli-obk
2 parents 485c5fb + 82d6e07 commit 1edcfc8

File tree

208 files changed

+10198
-4304
lines changed

Some content is hidden

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

208 files changed

+10198
-4304
lines changed

src/test/mir-opt/README.md

+2-80
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
This folder contains tests for MIR optimizations.
22

3-
There are two test formats. One allows specifying a pattern to look for in the MIR, which also
4-
permits leaving placeholders, but requires you to manually change the pattern if anything changes.
5-
The other emits MIR to extra files that you can automatically update by specifying `--bless` on
6-
the command line (just like `ui` tests updating `.stderr` files).
3+
The `mir-opt` test format emits MIR to extra files that you can automatically update by specifying
4+
`--bless` on the command line (just like `ui` tests updating `.stderr` files).
75

86
# `--bless`able test format
97

@@ -39,79 +37,3 @@ This exists mainly for completeness and is rarely useful.
3937
```
4038
// EMIT_MIR $file_name_of_some_mir_dump.before.mir
4139
```
42-
43-
# Inline test format
44-
45-
```
46-
(arbitrary rust code)
47-
// END RUST SOURCE
48-
// START $file_name_of_some_mir_dump_0
49-
// $expected_line_0
50-
// (lines or elision)
51-
// $expected_line_N
52-
// END $file_name_of_some_mir_dump_0
53-
// (lines or elision)
54-
// START $file_name_of_some_mir_dump_N
55-
// $expected_line_0
56-
// (lines or elision)
57-
// $expected_line_N
58-
// END $file_name_of_some_mir_dump_N
59-
```
60-
61-
All the test information is in comments so the test is runnable.
62-
63-
For each $file_name, compiletest expects [$expected_line_0, ...,
64-
$expected_line_N] to appear in the dumped MIR in order. Currently it allows
65-
other non-matched lines before and after, but not between $expected_lines,
66-
should you want to skip lines, you must include an elision comment, of the form
67-
(as a regex) `//\s*...\s*`. The lines will be skipped lazily, that is, if there
68-
are two identical lines in the output that match the line after the elision
69-
comment, the first one will be matched.
70-
71-
Examples:
72-
73-
The following blocks will not match the one after it.
74-
75-
```
76-
bb0: {
77-
StorageLive(_1);
78-
_1 = const true;
79-
StorageDead(_1);
80-
}
81-
```
82-
83-
```
84-
bb0: {
85-
StorageLive(_1);
86-
_1 = const true;
87-
goto -> bb1
88-
}
89-
bb1: {
90-
StorageDead(_1);
91-
return;
92-
}
93-
```
94-
95-
But this will match the one above,
96-
97-
```
98-
bb0: {
99-
StorageLive(_1);
100-
_1 = const true;
101-
...
102-
StorageDead(_1);
103-
...
104-
}
105-
```
106-
107-
Lines match ignoring whitespace, and the prefix "//" is removed.
108-
109-
It also currently strips trailing comments -- partly because the full file path
110-
in "scope comments" is unpredictable and partly because tidy complains about
111-
the lines being too long.
112-
113-
compiletest handles dumping the MIR before and after every pass for you. The
114-
test writer only has to specify the file names of the dumped files (not the
115-
full path to the file) and what lines to expect. There is an option to rustc
116-
that tells it to dump the mir into some directly (rather then always dumping to
117-
the current directory).

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

+3-68
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// EMIT_MIR rustc.address_of_reborrow.SimplifyCfg-initial.after.mir
2+
13
fn address_of_reborrow() {
24
let y = &[0; 10];
35
let mut z = &mut [0; 10];
@@ -35,78 +37,11 @@ fn address_of_reborrow() {
3537
}
3638

3739
// The normal borrows here should be preserved
40+
// EMIT_MIR rustc.borrow_and_cast.SimplifyCfg-initial.after.mir
3841
fn borrow_and_cast(mut x: i32) {
3942
let p = &x as *const i32;
4043
let q = &mut x as *const i32;
4144
let r = &mut x as *mut i32;
4245
}
4346

4447
fn main() {}
45-
46-
// START rustc.address_of_reborrow.SimplifyCfg-initial.after.mir
47-
// bb0: {
48-
// ...
49-
// _5 = &raw const (*_1); // & to *const casts
50-
// ...
51-
// _7 = &raw const (*_1);
52-
// ...
53-
// _11 = &raw const (*_1);
54-
// ...
55-
// _14 = &raw const (*_1);
56-
// ...
57-
// _16 = &raw const (*_1);
58-
// ...
59-
// _17 = &raw const (*_1); // & to *const coercions
60-
// ...
61-
// _18 = &raw const (*_1);
62-
// ...
63-
// _20 = &raw const (*_1);
64-
// ...
65-
// _22 = &raw const (*_1);
66-
// ...
67-
// _24 = &raw const (*_2); // &mut to *const casts
68-
// ...
69-
// _26 = &raw const (*_2);
70-
// ...
71-
// _30 = &raw const (*_2);
72-
// ...
73-
// _33 = &raw const (*_2);
74-
// ...
75-
// _34 = &raw const (*_2); // &mut to *const coercions
76-
// ...
77-
// _35 = &raw const (*_2);
78-
// ...
79-
// _37 = &raw const (*_2);
80-
// ...
81-
// _39 = &raw const (*_2);
82-
// ...
83-
// _41 = &raw mut (*_2); // &mut to *mut casts
84-
// ...
85-
// _43 = &raw mut (*_2);
86-
// ...
87-
// _47 = &raw mut (*_2);
88-
// ...
89-
// _50 = &raw mut (*_2);
90-
// ...
91-
// _51 = &raw mut (*_2); // &mut to *mut coercions
92-
// ...
93-
// _52 = &raw mut (*_2);
94-
// ...
95-
// _54 = &raw mut (*_2);
96-
// ...
97-
// _56 = &raw mut (*_2);
98-
// ...
99-
// }
100-
// END rustc.address_of_reborrow.SimplifyCfg-initial.after.mir
101-
102-
// START rustc.borrow_and_cast.EraseRegions.after.mir
103-
// bb0: {
104-
// ...
105-
// _4 = &_1;
106-
// ...
107-
// _7 = &mut _1;
108-
// ...
109-
// _10 = &mut _1;
110-
// ...
111-
// }
112-
// END rustc.borrow_and_cast.EraseRegions.after.mir

0 commit comments

Comments
 (0)