Skip to content

Commit 145df3b

Browse files
Rollup merge of #115293 - cjgillot:no-fuel, r=wesleywiser,DianQK
Remove -Zfuel. I'm not sure this feature is used. I only found 2 references in a google search, both referring to its introduction. Meanwhile, it's a global mutable state, untracked by incremental compilation, so incompatible with it.
2 parents dd2837e + 982cde9 commit 145df3b

28 files changed

+19
-293
lines changed

compiler/rustc_driver_impl/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,6 @@ fn run_compiler(
472472
linker.link(sess, codegen_backend)?
473473
}
474474

475-
if let Some(fuel) = sess.opts.unstable_opts.print_fuel.as_deref() {
476-
eprintln!("Fuel used by {}: {}", fuel, sess.print_fuel.load(Ordering::SeqCst));
477-
}
478-
479475
Ok(())
480476
})
481477
}

compiler/rustc_interface/src/tests.rs

-2
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,6 @@ fn test_unstable_options_tracking_hash() {
784784
tracked!(flatten_format_args, false);
785785
tracked!(fmt_debug, FmtDebug::Shallow);
786786
tracked!(force_unstable_if_unmarked, true);
787-
tracked!(fuel, Some(("abc".to_string(), 99)));
788787
tracked!(function_return, FunctionReturn::ThunkExtern);
789788
tracked!(function_sections, Some(false));
790789
tracked!(human_readable_cgu_names, true);
@@ -830,7 +829,6 @@ fn test_unstable_options_tracking_hash() {
830829
tracked!(plt, Some(true));
831830
tracked!(polonius, Polonius::Legacy);
832831
tracked!(precise_enum_drop_elaboration, false);
833-
tracked!(print_fuel, Some("abc".to_string()));
834832
tracked!(profile_sample_use, Some(PathBuf::from("abc")));
835833
tracked!(profiler_runtime, "abc".to_string());
836834
tracked!(regparm, Some(3));

compiler/rustc_middle/src/ty/context.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1566,10 +1566,6 @@ impl<'tcx> TyCtxt<'tcx> {
15661566
}
15671567
}
15681568

1569-
pub fn consider_optimizing<T: Fn() -> String>(self, msg: T) -> bool {
1570-
self.sess.consider_optimizing(|| self.crate_name(LOCAL_CRATE), msg)
1571-
}
1572-
15731569
/// Obtain all lang items of this crate and all dependencies (recursively)
15741570
pub fn lang_items(self) -> &'tcx rustc_hir::lang_items::LanguageItems {
15751571
self.get_lang_items(())

compiler/rustc_middle/src/ty/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1558,10 +1558,7 @@ impl<'tcx> TyCtxt<'tcx> {
15581558
let is_box = self.is_lang_item(did.to_def_id(), LangItem::OwnedBox);
15591559

15601560
// This is here instead of layout because the choice must make it into metadata.
1561-
if is_box
1562-
|| !self
1563-
.consider_optimizing(|| format!("Reorder fields of {:?}", self.def_path_str(did)))
1564-
{
1561+
if is_box {
15651562
flags.insert(ReprFlags::IS_LINEAR);
15661563
}
15671564

compiler/rustc_mir_transform/src/dest_prop.rs

-5
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,6 @@ impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation {
217217
else {
218218
continue;
219219
};
220-
if !tcx.consider_optimizing(|| {
221-
format!("{} round {}", tcx.def_path_str(def_id), round_count)
222-
}) {
223-
break;
224-
}
225220

226221
// Replace `src` by `dest` everywhere.
227222
merges.insert(*src, *dest);

compiler/rustc_mir_transform/src/early_otherwise_branch.rs

-4
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ impl<'tcx> crate::MirPass<'tcx> for EarlyOtherwiseBranch {
108108
let parent = BasicBlock::from_usize(i);
109109
let Some(opt_data) = evaluate_candidate(tcx, body, parent) else { continue };
110110

111-
if !tcx.consider_optimizing(|| format!("EarlyOtherwiseBranch {opt_data:?}")) {
112-
break;
113-
}
114-
115111
trace!("SUCCESS: found optimization possibility to apply: {opt_data:?}");
116112

117113
should_cleanup = true;

compiler/rustc_mir_transform/src/inline.rs

-6
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,6 @@ impl<'tcx> Inliner<'tcx> {
210210
let callee_body = try_instance_mir(self.tcx, callsite.callee.def)?;
211211
self.check_mir_body(callsite, callee_body, callee_attrs, cross_crate_inlinable)?;
212212

213-
if !self.tcx.consider_optimizing(|| {
214-
format!("Inline {:?} into {:?}", callsite.callee, caller_body.source)
215-
}) {
216-
return Err("optimization fuel exhausted");
217-
}
218-
219213
let Ok(callee_body) = callsite.callee.try_instantiate_mir_and_normalize_erasing_regions(
220214
self.tcx,
221215
self.typing_env,

compiler/rustc_mir_transform/src/instsimplify.rs

+14-57
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use rustc_middle::bug;
77
use rustc_middle::mir::*;
88
use rustc_middle::ty::layout::ValidityRequirement;
99
use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, layout};
10-
use rustc_span::sym;
1110
use rustc_span::symbol::Symbol;
11+
use rustc_span::{DUMMY_SP, sym};
1212

1313
use crate::simplify::simplify_duplicate_switch_targets;
1414
use crate::take_array;
@@ -43,12 +43,12 @@ impl<'tcx> crate::MirPass<'tcx> for InstSimplify {
4343
match statement.kind {
4444
StatementKind::Assign(box (_place, ref mut rvalue)) => {
4545
if !preserve_ub_checks {
46-
ctx.simplify_ub_check(&statement.source_info, rvalue);
46+
ctx.simplify_ub_check(rvalue);
4747
}
48-
ctx.simplify_bool_cmp(&statement.source_info, rvalue);
49-
ctx.simplify_ref_deref(&statement.source_info, rvalue);
50-
ctx.simplify_len(&statement.source_info, rvalue);
51-
ctx.simplify_ptr_aggregate(&statement.source_info, rvalue);
48+
ctx.simplify_bool_cmp(rvalue);
49+
ctx.simplify_ref_deref(rvalue);
50+
ctx.simplify_len(rvalue);
51+
ctx.simplify_ptr_aggregate(rvalue);
5252
ctx.simplify_cast(rvalue);
5353
}
5454
_ => {}
@@ -70,23 +70,8 @@ struct InstSimplifyContext<'a, 'tcx> {
7070
}
7171

7272
impl<'tcx> InstSimplifyContext<'_, 'tcx> {
73-
fn should_simplify(&self, source_info: &SourceInfo, rvalue: &Rvalue<'tcx>) -> bool {
74-
self.should_simplify_custom(source_info, "Rvalue", rvalue)
75-
}
76-
77-
fn should_simplify_custom(
78-
&self,
79-
source_info: &SourceInfo,
80-
label: &str,
81-
value: impl std::fmt::Debug,
82-
) -> bool {
83-
self.tcx.consider_optimizing(|| {
84-
format!("InstSimplify - {label}: {value:?} SourceInfo: {source_info:?}")
85-
})
86-
}
87-
8873
/// Transform boolean comparisons into logical operations.
89-
fn simplify_bool_cmp(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
74+
fn simplify_bool_cmp(&self, rvalue: &mut Rvalue<'tcx>) {
9075
match rvalue {
9176
Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), box (a, b)) => {
9277
let new = match (op, self.try_eval_bool(a), self.try_eval_bool(b)) {
@@ -117,9 +102,7 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
117102
_ => None,
118103
};
119104

120-
if let Some(new) = new
121-
&& self.should_simplify(source_info, rvalue)
122-
{
105+
if let Some(new) = new {
123106
*rvalue = new;
124107
}
125108
}
@@ -134,17 +117,13 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
134117
}
135118

136119
/// Transform `&(*a)` ==> `a`.
137-
fn simplify_ref_deref(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
120+
fn simplify_ref_deref(&self, rvalue: &mut Rvalue<'tcx>) {
138121
if let Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) = rvalue {
139122
if let Some((base, ProjectionElem::Deref)) = place.as_ref().last_projection() {
140123
if rvalue.ty(self.local_decls, self.tcx) != base.ty(self.local_decls, self.tcx).ty {
141124
return;
142125
}
143126

144-
if !self.should_simplify(source_info, rvalue) {
145-
return;
146-
}
147-
148127
*rvalue = Rvalue::Use(Operand::Copy(Place {
149128
local: base.local,
150129
projection: self.tcx.mk_place_elems(base.projection),
@@ -154,36 +133,24 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
154133
}
155134

156135
/// Transform `Len([_; N])` ==> `N`.
157-
fn simplify_len(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
136+
fn simplify_len(&self, rvalue: &mut Rvalue<'tcx>) {
158137
if let Rvalue::Len(ref place) = *rvalue {
159138
let place_ty = place.ty(self.local_decls, self.tcx).ty;
160139
if let ty::Array(_, len) = *place_ty.kind() {
161-
if !self.should_simplify(source_info, rvalue) {
162-
return;
163-
}
164-
165140
let const_ = Const::from_ty_const(len, self.tcx.types.usize, self.tcx);
166-
let constant = ConstOperand { span: source_info.span, const_, user_ty: None };
141+
let constant = ConstOperand { span: DUMMY_SP, const_, user_ty: None };
167142
*rvalue = Rvalue::Use(Operand::Constant(Box::new(constant)));
168143
}
169144
}
170145
}
171146

172147
/// Transform `Aggregate(RawPtr, [p, ()])` ==> `Cast(PtrToPtr, p)`.
173-
fn simplify_ptr_aggregate(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
148+
fn simplify_ptr_aggregate(&self, rvalue: &mut Rvalue<'tcx>) {
174149
if let Rvalue::Aggregate(box AggregateKind::RawPtr(pointee_ty, mutability), fields) = rvalue
175150
{
176151
let meta_ty = fields.raw[1].ty(self.local_decls, self.tcx);
177152
if meta_ty.is_unit() {
178153
// The mutable borrows we're holding prevent printing `rvalue` here
179-
if !self.should_simplify_custom(
180-
source_info,
181-
"Aggregate::RawPtr",
182-
(&pointee_ty, *mutability, &fields),
183-
) {
184-
return;
185-
}
186-
187154
let mut fields = std::mem::take(fields);
188155
let _meta = fields.pop().unwrap();
189156
let data = fields.pop().unwrap();
@@ -193,10 +160,10 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
193160
}
194161
}
195162

196-
fn simplify_ub_check(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
163+
fn simplify_ub_check(&self, rvalue: &mut Rvalue<'tcx>) {
197164
if let Rvalue::NullaryOp(NullOp::UbChecks, _) = *rvalue {
198165
let const_ = Const::from_bool(self.tcx, self.tcx.sess.ub_checks());
199-
let constant = ConstOperand { span: source_info.span, const_, user_ty: None };
166+
let constant = ConstOperand { span: DUMMY_SP, const_, user_ty: None };
200167
*rvalue = Rvalue::Use(Operand::Constant(Box::new(constant)));
201168
}
202169
}
@@ -284,16 +251,6 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
284251
return;
285252
}
286253

287-
if !self.tcx.consider_optimizing(|| {
288-
format!(
289-
"InstSimplify - Call: {:?} SourceInfo: {:?}",
290-
(fn_def_id, fn_args),
291-
terminator.source_info
292-
)
293-
}) {
294-
return;
295-
}
296-
297254
let Ok([arg]) = take_array(args) else { return };
298255
let Some(arg_place) = arg.node.place() else { return };
299256

compiler/rustc_mir_transform/src/match_branches.rs

-5
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,11 @@ impl<'tcx> crate::MirPass<'tcx> for MatchBranchSimplification {
1818
}
1919

2020
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
21-
let def_id = body.source.def_id();
2221
let typing_env = body.typing_env(tcx);
2322
let mut should_cleanup = false;
2423
for i in 0..body.basic_blocks.len() {
2524
let bbs = &*body.basic_blocks;
2625
let bb_idx = BasicBlock::from_usize(i);
27-
if !tcx.consider_optimizing(|| format!("MatchBranchSimplification {def_id:?} ")) {
28-
continue;
29-
}
30-
3126
match bbs[bb_idx].terminator().kind {
3227
TerminatorKind::SwitchInt {
3328
discr: ref _discr @ (Operand::Copy(_) | Operand::Move(_)),

compiler/rustc_mir_transform/src/multiple_return_terminators.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ impl<'tcx> crate::MirPass<'tcx> for MultipleReturnTerminators {
1414
sess.mir_opt_level() >= 4
1515
}
1616

17-
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
17+
fn run_pass(&self, _: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
1818
// find basic blocks with no statement and a return terminator
1919
let mut bbs_simple_returns = BitSet::new_empty(body.basic_blocks.len());
20-
let def_id = body.source.def_id();
2120
let bbs = body.basic_blocks_mut();
2221
for idx in bbs.indices() {
2322
if bbs[idx].statements.is_empty()
@@ -28,10 +27,6 @@ impl<'tcx> crate::MirPass<'tcx> for MultipleReturnTerminators {
2827
}
2928

3029
for bb in bbs {
31-
if !tcx.consider_optimizing(|| format!("MultipleReturnTerminators {def_id:?} ")) {
32-
break;
33-
}
34-
3530
if let TerminatorKind::Goto { target } = bb.terminator().kind {
3631
if bbs_simple_returns.contains(target) {
3732
bb.terminator_mut().kind = TerminatorKind::Return;

compiler/rustc_mir_transform/src/nrvo.rs

-4
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ impl<'tcx> crate::MirPass<'tcx> for RenameReturnPlace {
4545
return;
4646
};
4747

48-
if !tcx.consider_optimizing(|| format!("RenameReturnPlace {def_id:?}")) {
49-
return;
50-
}
51-
5248
debug!(
5349
"`{:?}` was eligible for NRVO, making {:?} the return place",
5450
def_id, returned_local

compiler/rustc_mir_transform/src/remove_unneeded_drops.rs

-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ impl<'tcx> crate::MirPass<'tcx> for RemoveUnneededDrops {
2626
if ty.ty.needs_drop(tcx, typing_env) {
2727
continue;
2828
}
29-
if !tcx.consider_optimizing(|| {
30-
format!("RemoveUnneededDrops {:?}", body.source.def_id())
31-
}) {
32-
continue;
33-
}
3429
debug!("SUCCESS: replacing `drop` with goto({:?})", target);
3530
terminator.kind = TerminatorKind::Goto { target };
3631
should_simplify = true;

compiler/rustc_mir_transform/src/remove_zsts.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ impl<'tcx> crate::MirPass<'tcx> for RemoveZsts {
1717
return;
1818
}
1919

20-
if !tcx.consider_optimizing(|| format!("RemoveZsts - {:?}", body.source.def_id())) {
21-
return;
22-
}
23-
2420
let typing_env = body.typing_env(tcx);
2521
let local_decls = &body.local_decls;
2622
let mut replacer = Replacer { tcx, typing_env, local_decls };
@@ -94,16 +90,12 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
9490
}
9591
}
9692

97-
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, loc: Location) {
93+
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, _: Location) {
9894
if let Operand::Constant(_) = operand {
9995
return;
10096
}
10197
let op_ty = operand.ty(self.local_decls, self.tcx);
102-
if self.known_to_be_zst(op_ty)
103-
&& self.tcx.consider_optimizing(|| {
104-
format!("RemoveZsts - Operand: {operand:?} Location: {loc:?}")
105-
})
106-
{
98+
if self.known_to_be_zst(op_ty) {
10799
*operand = Operand::Constant(Box::new(self.make_zst(op_ty)))
108100
}
109101
}

compiler/rustc_mir_transform/src/unreachable_prop.rs

-6
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ impl crate::MirPass<'_> for UnreachablePropagation {
4343
}
4444
}
4545

46-
if !tcx
47-
.consider_optimizing(|| format!("UnreachablePropagation {:?} ", body.source.def_id()))
48-
{
49-
return;
50-
}
51-
5246
patch.apply(body);
5347

5448
// We do want do keep some unreachable blocks, but make them empty.

compiler/rustc_session/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ session_not_supported = not supported
8484
8585
session_octal_float_literal_not_supported = octal float literal is not supported
8686
87-
session_optimization_fuel_exhausted = optimization-fuel-exhausted: {$msg}
88-
8987
session_profile_sample_use_file_does_not_exist = file `{$path}` passed to `-C profile-sample-use` does not exist
9088
9189
session_profile_use_file_does_not_exist = file `{$path}` passed to `-C profile-use` does not exist

compiler/rustc_session/src/config.rs

-8
Original file line numberDiff line numberDiff line change
@@ -2356,14 +2356,6 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
23562356
early_dcx.early_warn(format!("number of threads was capped at {}", parse::MAX_THREADS_CAP));
23572357
}
23582358

2359-
let fuel = unstable_opts.fuel.is_some() || unstable_opts.print_fuel.is_some();
2360-
if fuel && unstable_opts.threads > 1 {
2361-
early_dcx.early_fatal("optimization fuel is incompatible with multiple threads");
2362-
}
2363-
if fuel && cg.incremental.is_some() {
2364-
early_dcx.early_fatal("optimization fuel is incompatible with incremental compilation");
2365-
}
2366-
23672359
let incremental = cg.incremental.as_ref().map(PathBuf::from);
23682360

23692361
let assert_incr_state = parse_assert_incr_state(early_dcx, &unstable_opts.assert_incr_state);

compiler/rustc_session/src/errors.rs

-6
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,6 @@ pub fn report_lit_error(
463463
}
464464
}
465465

466-
#[derive(Diagnostic)]
467-
#[diag(session_optimization_fuel_exhausted)]
468-
pub(crate) struct OptimisationFuelExhausted {
469-
pub(crate) msg: String,
470-
}
471-
472466
#[derive(Diagnostic)]
473467
#[diag(session_incompatible_linker_flavor)]
474468
#[note]

0 commit comments

Comments
 (0)