Skip to content

Commit 6ce0b9f

Browse files
committed
Remove -Zfuel.
1 parent 26089ba commit 6ce0b9f

27 files changed

+14
-271
lines changed

compiler/rustc_driver_impl/src/lib.rs

-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use rustc_codegen_ssa::{traits::CodegenBackend, CodegenErrors, CodegenResults};
2424
use rustc_data_structures::profiling::{
2525
get_resident_set_size, print_time_passes_entry, TimePassesFormat,
2626
};
27-
use rustc_data_structures::sync::SeqCst;
2827
use rustc_errors::registry::{InvalidErrorCode, Registry};
2928
use rustc_errors::{markdown, ColorConfig};
3029
use rustc_errors::{DiagnosticMessage, ErrorGuaranteed, Handler, PResult, SubdiagnosticMessage};
@@ -474,14 +473,6 @@ fn run_compiler(
474473
sess.print_perf_stats();
475474
}
476475

477-
if sess.opts.unstable_opts.print_fuel.is_some() {
478-
eprintln!(
479-
"Fuel used by {}: {}",
480-
sess.opts.unstable_opts.print_fuel.as_ref().unwrap(),
481-
sess.print_fuel.load(SeqCst)
482-
);
483-
}
484-
485476
Ok(())
486477
})
487478
}

compiler/rustc_interface/src/tests.rs

-2
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,6 @@ fn test_unstable_options_tracking_hash() {
780780
tracked!(fewer_names, Some(true));
781781
tracked!(flatten_format_args, false);
782782
tracked!(force_unstable_if_unmarked, true);
783-
tracked!(fuel, Some(("abc".to_string(), 99)));
784783
tracked!(function_sections, Some(false));
785784
tracked!(human_readable_cgu_names, true);
786785
tracked!(incremental_ignore_spans, true);
@@ -817,7 +816,6 @@ fn test_unstable_options_tracking_hash() {
817816
tracked!(plt, Some(true));
818817
tracked!(polonius, true);
819818
tracked!(precise_enum_drop_elaboration, false);
820-
tracked!(print_fuel, Some("abc".to_string()));
821819
tracked!(profile, true);
822820
tracked!(profile_emit, Some(PathBuf::from("abc")));
823821
tracked!(profile_sample_use, Some(PathBuf::from("abc")));

compiler/rustc_middle/src/ty/context.rs

-4
Original file line numberDiff line numberDiff line change
@@ -738,10 +738,6 @@ impl<'tcx> TyCtxt<'tcx> {
738738
}
739739
}
740740

741-
pub fn consider_optimizing<T: Fn() -> String>(self, msg: T) -> bool {
742-
self.sess.consider_optimizing(|| self.crate_name(LOCAL_CRATE), msg)
743-
}
744-
745741
/// Obtain all lang items of this crate and all dependencies (recursively)
746742
pub fn lang_items(self) -> &'tcx rustc_hir::lang_items::LanguageItems {
747743
self.get_lang_items(())

compiler/rustc_middle/src/ty/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -2198,11 +2198,6 @@ impl<'tcx> TyCtxt<'tcx> {
21982198
flags.insert(ReprFlags::RANDOMIZE_LAYOUT);
21992199
}
22002200

2201-
// This is here instead of layout because the choice must make it into metadata.
2202-
if !self.consider_optimizing(|| format!("Reorder fields of {:?}", self.def_path_str(did))) {
2203-
flags.insert(ReprFlags::IS_LINEAR);
2204-
}
2205-
22062201
ReprOptions { int: size, align: max_align, pack: min_pack, flags, field_shuffle_seed }
22072202
}
22082203

compiler/rustc_mir_transform/src/const_prop.rs

-3
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
555555
// type whose creation requires no write. E.g. a generator whose initial state
556556
// consists solely of uninitialized memory (so it doesn't capture any locals).
557557
let value = self.get_const(place)?;
558-
if !self.tcx.consider_optimizing(|| format!("ConstantPropagation - {value:?}")) {
559-
return None;
560-
}
561558
trace!("replacing {:?} with {:?}", place, value);
562559

563560
// FIXME> figure out what to do when read_immediate_raw fails

compiler/rustc_mir_transform/src/dest_prop.rs

-5
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,6 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation {
222222
else {
223223
continue;
224224
};
225-
if !tcx.consider_optimizing(|| {
226-
format!("{} round {}", tcx.def_path_str(def_id), round_count)
227-
}) {
228-
break;
229-
}
230225
merges.insert(*src, *dest);
231226
merged_locals.insert(*src);
232227
merged_locals.insert(*dest);

compiler/rustc_mir_transform/src/early_otherwise_branch.rs

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

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

118114
should_cleanup = true;

compiler/rustc_mir_transform/src/inline.rs

-6
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,6 @@ impl<'tcx> Inliner<'tcx> {
187187
let callee_body = try_instance_mir(self.tcx, callsite.callee.def)?;
188188
self.check_mir_body(callsite, callee_body, callee_attrs)?;
189189

190-
if !self.tcx.consider_optimizing(|| {
191-
format!("Inline {:?} into {:?}", callsite.callee, caller_body.source)
192-
}) {
193-
return Err("optimization fuel exhausted");
194-
}
195-
196190
let Ok(callee_body) = callsite.callee.try_subst_mir_and_normalize_erasing_regions(
197191
self.tcx,
198192
self.param_env,

compiler/rustc_mir_transform/src/instsimplify.rs

+11-34
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_middle::mir::*;
77
use rustc_middle::ty::layout::ValidityRequirement;
88
use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt};
99
use rustc_span::symbol::Symbol;
10+
use rustc_span::DUMMY_SP;
1011
use rustc_target::abi::FieldIdx;
1112

1213
pub struct InstSimplify;
@@ -26,10 +27,10 @@ impl<'tcx> MirPass<'tcx> for InstSimplify {
2627
for statement in block.statements.iter_mut() {
2728
match statement.kind {
2829
StatementKind::Assign(box (_place, ref mut rvalue)) => {
29-
ctx.simplify_bool_cmp(&statement.source_info, rvalue);
30-
ctx.simplify_ref_deref(&statement.source_info, rvalue);
31-
ctx.simplify_len(&statement.source_info, rvalue);
32-
ctx.simplify_cast(&statement.source_info, rvalue);
30+
ctx.simplify_bool_cmp(rvalue);
31+
ctx.simplify_ref_deref(rvalue);
32+
ctx.simplify_len(rvalue);
33+
ctx.simplify_cast(rvalue);
3334
}
3435
_ => {}
3536
}
@@ -55,14 +56,8 @@ struct InstSimplifyContext<'tcx, 'a> {
5556
}
5657

5758
impl<'tcx> InstSimplifyContext<'tcx, '_> {
58-
fn should_simplify(&self, source_info: &SourceInfo, rvalue: &Rvalue<'tcx>) -> bool {
59-
self.tcx.consider_optimizing(|| {
60-
format!("InstSimplify - Rvalue: {rvalue:?} SourceInfo: {source_info:?}")
61-
})
62-
}
63-
6459
/// Transform boolean comparisons into logical operations.
65-
fn simplify_bool_cmp(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
60+
fn simplify_bool_cmp(&self, rvalue: &mut Rvalue<'tcx>) {
6661
match rvalue {
6762
Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), box (a, b)) => {
6863
let new = match (op, self.try_eval_bool(a), self.try_eval_bool(b)) {
@@ -93,7 +88,7 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
9388
_ => None,
9489
};
9590

96-
if let Some(new) = new && self.should_simplify(source_info, rvalue) {
91+
if let Some(new) = new {
9792
*rvalue = new;
9893
}
9994
}
@@ -108,17 +103,13 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
108103
}
109104

110105
/// Transform "&(*a)" ==> "a".
111-
fn simplify_ref_deref(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
106+
fn simplify_ref_deref(&self, rvalue: &mut Rvalue<'tcx>) {
112107
if let Rvalue::Ref(_, _, place) = rvalue {
113108
if let Some((base, ProjectionElem::Deref)) = place.as_ref().last_projection() {
114109
if rvalue.ty(self.local_decls, self.tcx) != base.ty(self.local_decls, self.tcx).ty {
115110
return;
116111
}
117112

118-
if !self.should_simplify(source_info, rvalue) {
119-
return;
120-
}
121-
122113
*rvalue = Rvalue::Use(Operand::Copy(Place {
123114
local: base.local,
124115
projection: self.tcx.mk_place_elems(base.projection),
@@ -128,22 +119,18 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
128119
}
129120

130121
/// Transform "Len([_; N])" ==> "N".
131-
fn simplify_len(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
122+
fn simplify_len(&self, rvalue: &mut Rvalue<'tcx>) {
132123
if let Rvalue::Len(ref place) = *rvalue {
133124
let place_ty = place.ty(self.local_decls, self.tcx).ty;
134125
if let ty::Array(_, len) = *place_ty.kind() {
135-
if !self.should_simplify(source_info, rvalue) {
136-
return;
137-
}
138-
139126
let literal = ConstantKind::from_const(len, self.tcx);
140-
let constant = Constant { span: source_info.span, literal, user_ty: None };
127+
let constant = Constant { span: DUMMY_SP, literal, user_ty: None };
141128
*rvalue = Rvalue::Use(Operand::Constant(Box::new(constant)));
142129
}
143130
}
144131
}
145132

146-
fn simplify_cast(&self, _source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
133+
fn simplify_cast(&self, rvalue: &mut Rvalue<'tcx>) {
147134
if let Rvalue::Cast(kind, operand, cast_ty) = rvalue {
148135
let operand_ty = operand.ty(self.local_decls, self.tcx);
149136
if operand_ty == *cast_ty {
@@ -223,16 +210,6 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
223210
return;
224211
}
225212

226-
if !self.tcx.consider_optimizing(|| {
227-
format!(
228-
"InstSimplify - Call: {:?} SourceInfo: {:?}",
229-
(fn_def_id, fn_args),
230-
terminator.source_info
231-
)
232-
}) {
233-
return;
234-
}
235-
236213
let Some(arg_place) = args.pop().unwrap().place() else { return };
237214

238215
statements.push(Statement {

compiler/rustc_mir_transform/src/match_branches.rs

-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
5151
let bbs = body.basic_blocks.as_mut();
5252
let mut should_cleanup = false;
5353
'outer: for bb_idx in bbs.indices() {
54-
if !tcx.consider_optimizing(|| format!("MatchBranchSimplification {def_id:?} ")) {
55-
continue;
56-
}
57-
5854
let (discr, val, first, second) = match bbs[bb_idx].terminator().kind {
5955
TerminatorKind::SwitchInt {
6056
discr: ref discr @ (Operand::Copy(_) | Operand::Move(_)),

compiler/rustc_mir_transform/src/multiple_return_terminators.rs

-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ impl<'tcx> MirPass<'tcx> for MultipleReturnTerminators {
1616
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
1717
// find basic blocks with no statement and a return terminator
1818
let mut bbs_simple_returns = BitSet::new_empty(body.basic_blocks.len());
19-
let def_id = body.source.def_id();
2019
let bbs = body.basic_blocks_mut();
2120
for idx in bbs.indices() {
2221
if bbs[idx].statements.is_empty()
@@ -27,10 +26,6 @@ impl<'tcx> MirPass<'tcx> for MultipleReturnTerminators {
2726
}
2827

2928
for bb in bbs {
30-
if !tcx.consider_optimizing(|| format!("MultipleReturnTerminators {def_id:?} ")) {
31-
break;
32-
}
33-
3429
if let TerminatorKind::Goto { target } = bb.terminator().kind {
3530
if bbs_simple_returns.contains(target) {
3631
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> 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

-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops {
2727
if ty.ty.needs_drop(tcx, param_env) {
2828
continue;
2929
}
30-
if !tcx.consider_optimizing(|| format!("RemoveUnneededDrops {did:?} ")) {
31-
continue;
32-
}
3330
debug!("SUCCESS: replacing `drop` with goto({:?})", target);
3431
terminator.kind = TerminatorKind::Goto { target };
3532
should_simplify = true;

compiler/rustc_mir_transform/src/remove_zsts.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,12 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
9595
}
9696
}
9797

98-
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, loc: Location) {
98+
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, _: Location) {
9999
if let Operand::Constant(_) = operand {
100100
return;
101101
}
102102
let op_ty = operand.ty(self.local_decls, self.tcx);
103-
if self.known_to_be_zst(op_ty)
104-
&& self.tcx.consider_optimizing(|| {
105-
format!("RemoveZsts - Operand: {operand:?} Location: {loc:?}")
106-
})
107-
{
103+
if self.known_to_be_zst(op_ty) {
108104
*operand = Operand::Constant(Box::new(self.make_zst(op_ty)))
109105
}
110106
}
@@ -131,9 +127,6 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
131127
if let Some(place_for_ty) = place_for_ty
132128
&& let ty = place_for_ty.ty(self.local_decls, self.tcx).ty
133129
&& self.known_to_be_zst(ty)
134-
&& self.tcx.consider_optimizing(|| {
135-
format!("RemoveZsts - Place: {:?} SourceInfo: {:?}", place_for_ty, statement.source_info)
136-
})
137130
{
138131
statement.make_nop();
139132
} else {

compiler/rustc_mir_transform/src/unreachable_prop.rs

-12
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,12 @@ impl MirPass<'_> for UnreachablePropagation {
3939

4040
// We do want do keep some unreachable blocks, but make them empty.
4141
for bb in unreachable_blocks {
42-
if !tcx.consider_optimizing(|| {
43-
format!("UnreachablePropagation {:?} ", body.source.def_id())
44-
}) {
45-
break;
46-
}
47-
4842
body.basic_blocks_mut()[bb].statements.clear();
4943
}
5044

5145
let replaced = !replacements.is_empty();
5246

5347
for (bb, terminator_kind) in replacements {
54-
if !tcx.consider_optimizing(|| {
55-
format!("UnreachablePropagation {:?} ", body.source.def_id())
56-
}) {
57-
break;
58-
}
59-
6048
body.basic_blocks_mut()[bb].terminator_mut().kind = terminator_kind;
6149
}
6250

compiler/rustc_session/messages.ftl

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ session_not_supported = not supported
8080
session_nul_in_c_str = null characters in C string literals are not supported
8181
8282
session_octal_float_literal_not_supported = octal float literal is not supported
83-
session_optimization_fuel_exhausted = optimization-fuel-exhausted: {$msg}
8483
8584
session_profile_sample_use_file_does_not_exist = file `{$path}` passed to `-C profile-sample-use` does not exist.
8685

compiler/rustc_session/src/config.rs

-4
Original file line numberDiff line numberDiff line change
@@ -2107,10 +2107,6 @@ fn check_thread_count(handler: &EarlyErrorHandler, unstable_opts: &UnstableOptio
21072107
if unstable_opts.threads == 0 {
21082108
handler.early_error("value for threads must be a positive non-zero integer");
21092109
}
2110-
2111-
if unstable_opts.threads > 1 && unstable_opts.fuel.is_some() {
2112-
handler.early_error("optimization fuel is incompatible with multiple threads");
2113-
}
21142110
}
21152111

21162112
fn collect_print_requests(

compiler/rustc_session/src/errors.rs

-6
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,6 @@ pub fn report_lit_error(sess: &ParseSess, err: LitError, lit: token::Lit, span:
442442
}
443443
}
444444

445-
#[derive(Diagnostic)]
446-
#[diag(session_optimization_fuel_exhausted)]
447-
pub struct OptimisationFuelExhausted {
448-
pub msg: String,
449-
}
450-
451445
#[derive(Diagnostic)]
452446
#[diag(session_incompatible_linker_flavor)]
453447
#[note]

0 commit comments

Comments
 (0)