diff options
| author | Bryan Cantrill <bcantrill@acm.org> | 2021-08-07 01:12:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-07 10:12:22 +0200 |
| commit | 630c8fe7a3c933f7554ea4d786013d32fc0a2082 (patch) | |
| tree | 109e7f7c647901b7ffb93398e6c9f6277a141961 /src/doc/rustc-dev-guide | |
| parent | 9d5a487ffd2258ce275e9b752927844c4c8c916b (diff) | |
| download | rust-630c8fe7a3c933f7554ea4d786013d32fc0a2082.tar.gz rust-630c8fe7a3c933f7554ea4d786013d32fc0a2082.zip | |
Add description of -opt-bisect-limit LLVM option (#1182)
Diffstat (limited to 'src/doc/rustc-dev-guide')
| -rw-r--r-- | src/doc/rustc-dev-guide/src/backend/debugging.md | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/doc/rustc-dev-guide/src/backend/debugging.md b/src/doc/rustc-dev-guide/src/backend/debugging.md index 7577a0e13dd..67366016765 100644 --- a/src/doc/rustc-dev-guide/src/backend/debugging.md +++ b/src/doc/rustc-dev-guide/src/backend/debugging.md @@ -56,6 +56,17 @@ different stages during compilation, which is sometimes useful. One just needs to convert the bitcode files to `.ll` files using `llvm-dis` which should be in the target local compilation of rustc. +If you are seeing incorrect behavior due to an optimization pass, a very handy +LLVM option is `-opt-bisect-limit`, which takes an integer denoting the index +value of the highest pass to run. Index values for taken passes are stable +from run to run; by coupling this with software that automates bisecting the +search space based on the resulting program, an errant pass can be quickly +determined. When an `-opt-bisect-limit` is specified, all runs are displayed +to standard error, along with their index and output indicating if the +pass was run or skipped. Setting the limit to an index of -1 (e.g., +`RUSTFLAGS="-C llvm-args=-opt-bisect-limit=-1"`) will show all passes and +their corresponding index values. + If you want to play with the optimization pipeline, you can use the `opt` tool from `./build/<host-triple>/llvm/bin/` with the LLVM IR emitted by rustc. Note that rustc emits different IR depending on whether `-O` is enabled, even @@ -125,6 +136,8 @@ tutorial above): - The `-Z no-parallel-llvm` will disable parallel compilation of distinct compilation units - The `-Z llvm-time-trace` option will output a Chrome profiler compatible JSON file which contains details and timings for LLVM passes. +- The `-C llvm-args=-opt-bisect-limit=<index>` option allows for bisecting LLVM + optimizations. ### Filing LLVM bug reports |
