From 157db48097637eec482abac07551033dea57b2e1 Mon Sep 17 00:00:00 2001 From: cjkenn Date: Fri, 20 Nov 2020 14:51:29 -0500 Subject: add small explanation of why fuel can be useful for debugging --- src/doc/rustc-dev-guide/src/mir/optimizations.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/doc/rustc-dev-guide') diff --git a/src/doc/rustc-dev-guide/src/mir/optimizations.md b/src/doc/rustc-dev-guide/src/mir/optimizations.md index b34520f353d..080c8fd3fb0 100644 --- a/src/doc/rustc-dev-guide/src/mir/optimizations.md +++ b/src/doc/rustc-dev-guide/src/mir/optimizations.md @@ -65,8 +65,10 @@ current level using `tcx.sess.opts.debugging_opts.mir_opt_level`. Optimization fuel is a compiler option (`-Z fuel==`) that allows for fine grained control over which optimizations can be applied during compilation: each optimization reduces -fuel by 1, and when fuel reaches 0 no more optimizations are applied. This can help with debugging -and identifying problems with optimizations. +fuel by 1, and when fuel reaches 0 no more optimizations are applied. The primary use of fuel +is debugging optimizations that may be incorrect or misapplied. By changing the fuel +value, you can bisect a compilation session down to the exact incorrect optimization +(this behaves like a kind of binary search through the optimizations). MIR optimizations respect fuel, and in general each pass should check fuel by calling [`tcx.consider_optimizing`][consideroptimizing] and skipping the optimization if fuel -- cgit 1.4.1-3-g733a5