From 49069a02333ace60b363e3071fc4907353d50492 Mon Sep 17 00:00:00 2001 From: cjkenn Date: Fri, 20 Nov 2020 14:51:29 -0500 Subject: [PATCH] add small explanation of why fuel can be useful for debugging --- src/mir/optimizations.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mir/optimizations.md b/src/mir/optimizations.md index b34520f3..080c8fd3 100644 --- a/src/mir/optimizations.md +++ b/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