Skip to content

Commit e218184

Browse files
authored
Add description of -opt-bisect-limit LLVM option (#1182)
1 parent 809f4d1 commit e218184

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/backend/debugging.md

+13
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ different stages during compilation, which is sometimes useful. One just needs
5656
to convert the bitcode files to `.ll` files using `llvm-dis` which should be in
5757
the 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+
5970
If you want to play with the optimization pipeline, you can use the `opt` tool
6071
from `./build/<host-triple>/llvm/bin/` with the LLVM IR emitted by rustc. Note
6172
that 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

Comments
 (0)