]>
Commit | Line | Data |
---|---|---|
5bcae85e SL |
1 | This folder contains tests for MIR optimizations. |
2 | ||
ba9703b0 XL |
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). | |
5 | ||
6 | # `--bless`able test format | |
7 | ||
8 | By default 32 bit and 64 bit targets use the same dump files, which can be problematic in the | |
9 | presence of pointers in constants or other bit width dependent things. In that case you can add | |
5bcae85e SL |
10 | |
11 | ``` | |
ba9703b0 | 12 | // EMIT_MIR_FOR_EACH_BIT_WIDTH |
5bcae85e SL |
13 | ``` |
14 | ||
ba9703b0 | 15 | to your test, causing separate files to be generated for 32bit and 64bit systems. |
5bcae85e | 16 | |
f2b60f7d FG |
17 | ## Unit testing |
18 | ||
19 | If you are only testing the behavior of a particular mir-opt pass on some specific input (as is | |
20 | usually the case), you should add | |
21 | ||
22 | ``` | |
23 | // unit-test: PassName | |
24 | ``` | |
25 | ||
26 | to the top of the file. This makes sure that other passes don't run which means you'll get the input | |
27 | you expected and your test won't break when other code changes. | |
28 | ||
ba9703b0 | 29 | ## Emit a diff of the mir for a specific optimization |
abe05a73 | 30 | |
ba9703b0 | 31 | This is what you want most often when you want to see how an optimization changes the MIR. |
041b39d2 XL |
32 | |
33 | ``` | |
ba9703b0 | 34 | // EMIT_MIR $file_name_of_some_mir_dump.diff |
041b39d2 XL |
35 | ``` |
36 | ||
ba9703b0 | 37 | ## Emit mir after a specific optimization |
5bcae85e | 38 | |
ba9703b0 | 39 | Use this if you are just interested in the final state after an optimization. |
abe05a73 XL |
40 | |
41 | ``` | |
ba9703b0 | 42 | // EMIT_MIR $file_name_of_some_mir_dump.after.mir |
abe05a73 XL |
43 | ``` |
44 | ||
ba9703b0 | 45 | ## Emit mir before a specific optimization |
5bcae85e | 46 | |
ba9703b0 | 47 | This exists mainly for completeness and is rarely useful. |
5bcae85e | 48 | |
ba9703b0 XL |
49 | ``` |
50 | // EMIT_MIR $file_name_of_some_mir_dump.before.mir | |
51 | ``` |