@@ -56,6 +56,17 @@ different stages during compilation, which is sometimes useful. One just needs
56
56
to convert the bitcode files to ` .ll ` files using ` llvm-dis ` which should be in
57
57
the target local compilation of rustc.
58
58
59
+ If you are seeing incorrect behavior due to an optimization pass, a very handy
60
+ LLVM option is ` -opt-bisect-limit ` , which takes an integer denoting the index
61
+ value of the highest pass to run. Index values for taken passes are stable
62
+ from run to run; by coupling this with software that automates bisecting the
63
+ search space based on the resulting program, an errant pass can be quickly
64
+ determined. When an ` -opt-bisect-limit ` is specified, all runs are displayed
65
+ to standard error, along with their index and output indicating if the
66
+ pass was run or skipped. Setting the limit to an index of -1 (e.g.,
67
+ ` RUSTFLAGS="-C llvm-args=-opt-bisect-limit=-1" ` ) will show all passes and
68
+ their corresponding index values.
69
+
59
70
If you want to play with the optimization pipeline, you can use the ` opt ` tool
60
71
from ` ./build/<host-triple>/llvm/bin/ ` with the LLVM IR emitted by rustc. Note
61
72
that rustc emits different IR depending on whether ` -O ` is enabled, even
@@ -125,6 +136,8 @@ tutorial above):
125
136
- The ` -Z no-parallel-llvm ` will disable parallel compilation of distinct compilation units
126
137
- The ` -Z llvm-time-trace ` option will output a Chrome profiler compatible JSON file
127
138
which contains details and timings for LLVM passes.
139
+ - The ` -C llvm-args=-opt-bisect-limit=<index> ` option allows for bisecting LLVM
140
+ optimizations.
128
141
129
142
### Filing LLVM bug reports
130
143
0 commit comments