@@ -56,6 +56,17 @@ different stages during compilation, which is sometimes useful. One just needs
5656to convert the bitcode files to ` .ll ` files using ` llvm-dis ` which should be in
5757the target local compilation of rustc.
5858
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+
5970If you want to play with the optimization pipeline, you can use the ` opt ` tool
6071from ` ./build/<host-triple>/llvm/bin/ ` with the LLVM IR emitted by rustc. Note
6172that rustc emits different IR depending on whether ` -O ` is enabled, even
@@ -125,6 +136,8 @@ tutorial above):
125136- The ` -Z no-parallel-llvm ` will disable parallel compilation of distinct compilation units
126137- The ` -Z llvm-time-trace ` option will output a Chrome profiler compatible JSON file
127138 which contains details and timings for LLVM passes.
139+ - The ` -C llvm-args=-opt-bisect-limit=<index> ` option allows for bisecting LLVM
140+ optimizations.
128141
129142### Filing LLVM bug reports
130143
0 commit comments