]> git.proxmox.com Git - rustc.git/blame - src/test/mir-opt/README.md
Update unsuspicious file list
[rustc.git] / src / test / mir-opt / README.md
CommitLineData
5bcae85e
SL
1This folder contains tests for MIR optimizations.
2
ba9703b0
XL
3The `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
8By default 32 bit and 64 bit targets use the same dump files, which can be problematic in the
9presence 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 15to your test, causing separate files to be generated for 32bit and 64bit systems.
5bcae85e 16
f2b60f7d
FG
17## Unit testing
18
19If you are only testing the behavior of a particular mir-opt pass on some specific input (as is
20usually the case), you should add
21
22```
23// unit-test: PassName
24```
25
26to the top of the file. This makes sure that other passes don't run which means you'll get the input
27you 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 31This 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 39Use 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 47This 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```