diff options
| author | Dániel Buga <bugadani@gmail.com> | 2020-09-23 22:29:17 +0200 |
|---|---|---|
| committer | Joshua Nelson <joshua@yottadb.com> | 2020-09-23 18:42:23 -0400 |
| commit | 9373c8d588f78b43903423b63a2223fdc38f3d88 (patch) | |
| tree | 150dfd06c101dee056254cc3a03afeee513d24f6 /src/doc/rustc-dev-guide | |
| parent | 30ca044a7199d13a357a89ddf45c3f23729d5e4c (diff) | |
| download | rust-9373c8d588f78b43903423b63a2223fdc38f3d88.tar.gz rust-9373c8d588f78b43903423b63a2223fdc38f3d88.zip | |
Link to the -Zmir-opt-level proposal
I was confused about what the different levels mean. This PR adds a paragraph that shortly explains the rationale behind different mir-opt-levels and links to the current proposal where there's some information about them. Let me know if I wrote something unreasonable or incorrect. Co-authored-by: Joshua Nelson <joshua@yottadb.com>
Diffstat (limited to 'src/doc/rustc-dev-guide')
| -rw-r--r-- | src/doc/rustc-dev-guide/src/mir/optimizations.md | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/doc/rustc-dev-guide/src/mir/optimizations.md b/src/doc/rustc-dev-guide/src/mir/optimizations.md index 3c143d55576..65323ed52e4 100644 --- a/src/doc/rustc-dev-guide/src/mir/optimizations.md +++ b/src/doc/rustc-dev-guide/src/mir/optimizations.md @@ -36,7 +36,7 @@ implemented in its own submodule of the [`rustc_mir::transform`][trans] module. [rop]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/transform/fn.run_optimization_passes.html [`MirPass`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/transform/trait.MirPass.html -[trans]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/transform/index.html +[trans]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/transform/index.html Some examples of passes are: - `CleanupNonCodegenStatements`: remove some of the info that is only needed for @@ -47,3 +47,16 @@ You can see the ["Implementors" section of the `MirPass` rustdocs][impl] for mor [impl]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/transform/trait.MirPass.html#implementors [constprop]: https://en.wikipedia.org/wiki/Constant_folding#Constant_propagation + +## MIR optimization levels + +MIR optimizations can come in various levels of readiness. Experimental +optimizations may cause miscompilations, or slow down compile times. +These passes are still included in nightly builds to gather feedback and make it easier to modify +the pass. To enable working with slow or otherwise experimental optimization passes, +you can specify the `-Z mir-opt-level` debug flag. You can find the +definitions of the levels in the [compiler MCP]. If you are developing a MIR pass and +want to query whether your optimization pass should run, you can check the +current level using `tcx.sess.opts.debugging_opts.mir_opt_level`. + +[compiler MCP]: https://github.com/rust-lang/compiler-team/issues/319 |
