Skip to content

Commit 287ed76

Browse files
committed
Remove -Zfuel.
1 parent a32d4a0 commit 287ed76

26 files changed

+18
-283
lines changed

compiler/rustc_driver_impl/src/lib.rs

-8
Original file line numberDiff line numberDiff line change
@@ -463,14 +463,6 @@ fn run_compiler(
463463
linker.link(sess, codegen_backend)?
464464
}
465465

466-
if sess.opts.unstable_opts.print_fuel.is_some() {
467-
eprintln!(
468-
"Fuel used by {}: {}",
469-
sess.opts.unstable_opts.print_fuel.as_ref().unwrap(),
470-
sess.print_fuel.load(Ordering::SeqCst)
471-
);
472-
}
473-
474466
Ok(())
475467
})
476468
}

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!(fixed_x18, 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_return, FunctionReturn::ThunkExtern);
785784
tracked!(function_sections, Some(false));
786785
tracked!(human_readable_cgu_names, true);
@@ -825,7 +824,6 @@ fn test_unstable_options_tracking_hash() {
825824
tracked!(plt, Some(true));
826825
tracked!(polonius, Polonius::Legacy);
827826
tracked!(precise_enum_drop_elaboration, false);
828-
tracked!(print_fuel, Some("abc".to_string()));
829827
tracked!(profile, true);
830828
tracked!(profile_emit, Some(PathBuf::from("abc")));
831829
tracked!(profile_sample_use, Some(PathBuf::from("abc")));

compiler/rustc_middle/src/ty/context.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1529,10 +1529,6 @@ impl<'tcx> TyCtxt<'tcx> {
15291529
}
15301530
}
15311531

1532-
pub fn consider_optimizing<T: Fn() -> String>(self, msg: T) -> bool {
1533-
self.sess.consider_optimizing(|| self.crate_name(LOCAL_CRATE), msg)
1534-
}
1535-
15361532
/// Obtain all lang items of this crate and all dependencies (recursively)
15371533
pub fn lang_items(self) -> &'tcx rustc_hir::lang_items::LanguageItems {
15381534
self.get_lang_items(())

compiler/rustc_middle/src/ty/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1570,11 +1570,6 @@ impl<'tcx> TyCtxt<'tcx> {
15701570
flags.insert(ReprFlags::RANDOMIZE_LAYOUT);
15711571
}
15721572

1573-
// This is here instead of layout because the choice must make it into metadata.
1574-
if !self.consider_optimizing(|| format!("Reorder fields of {:?}", self.def_path_str(did))) {
1575-
flags.insert(ReprFlags::IS_LINEAR);
1576-
}
1577-
15781573
ReprOptions { int: size, align: max_align, pack: min_pack, flags, field_shuffle_seed }
15791574
}
15801575

compiler/rustc_mir_transform/src/dest_prop.rs

-5
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,6 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation {
225225
else {
226226
continue;
227227
};
228-
if !tcx.consider_optimizing(|| {
229-
format!("{} round {}", tcx.def_path_str(def_id), round_count)
230-
}) {
231-
break;
232-
}
233228

234229
// Replace `src` by `dest` everywhere.
235230
merges.insert(*src, *dest);

compiler/rustc_mir_transform/src/early_otherwise_branch.rs

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

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

116112
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.param_env,

compiler/rustc_mir_transform/src/instsimplify.rs

+14-57
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use rustc_middle::bug;
66
use rustc_middle::mir::*;
77
use rustc_middle::ty::layout::ValidityRequirement;
88
use rustc_middle::ty::{self, layout, GenericArgsRef, ParamEnv, Ty, TyCtxt};
9-
use rustc_span::sym;
109
use rustc_span::symbol::Symbol;
10+
use rustc_span::{sym, DUMMY_SP};
1111
use rustc_target::spec::abi::Abi;
1212

1313
use crate::simplify::simplify_duplicate_switch_targets;
@@ -49,12 +49,12 @@ impl<'tcx> MirPass<'tcx> for InstSimplify {
4949
match statement.kind {
5050
StatementKind::Assign(box (_place, ref mut rvalue)) => {
5151
if !preserve_ub_checks {
52-
ctx.simplify_ub_check(&statement.source_info, rvalue);
52+
ctx.simplify_ub_check(rvalue);
5353
}
54-
ctx.simplify_bool_cmp(&statement.source_info, rvalue);
55-
ctx.simplify_ref_deref(&statement.source_info, rvalue);
56-
ctx.simplify_len(&statement.source_info, rvalue);
57-
ctx.simplify_ptr_aggregate(&statement.source_info, rvalue);
54+
ctx.simplify_bool_cmp(rvalue);
55+
ctx.simplify_ref_deref(rvalue);
56+
ctx.simplify_len(rvalue);
57+
ctx.simplify_ptr_aggregate(rvalue);
5858
ctx.simplify_cast(rvalue);
5959
}
6060
_ => {}
@@ -76,23 +76,8 @@ struct InstSimplifyContext<'tcx, 'a> {
7676
}
7777

7878
impl<'tcx> InstSimplifyContext<'tcx, '_> {
79-
fn should_simplify(&self, source_info: &SourceInfo, rvalue: &Rvalue<'tcx>) -> bool {
80-
self.should_simplify_custom(source_info, "Rvalue", rvalue)
81-
}
82-
83-
fn should_simplify_custom(
84-
&self,
85-
source_info: &SourceInfo,
86-
label: &str,
87-
value: impl std::fmt::Debug,
88-
) -> bool {
89-
self.tcx.consider_optimizing(|| {
90-
format!("InstSimplify - {label}: {value:?} SourceInfo: {source_info:?}")
91-
})
92-
}
93-
9479
/// Transform boolean comparisons into logical operations.
95-
fn simplify_bool_cmp(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
80+
fn simplify_bool_cmp(&self, rvalue: &mut Rvalue<'tcx>) {
9681
match rvalue {
9782
Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), box (a, b)) => {
9883
let new = match (op, self.try_eval_bool(a), self.try_eval_bool(b)) {
@@ -123,9 +108,7 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
123108
_ => None,
124109
};
125110

126-
if let Some(new) = new
127-
&& self.should_simplify(source_info, rvalue)
128-
{
111+
if let Some(new) = new {
129112
*rvalue = new;
130113
}
131114
}
@@ -140,17 +123,13 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
140123
}
141124

142125
/// Transform `&(*a)` ==> `a`.
143-
fn simplify_ref_deref(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
126+
fn simplify_ref_deref(&self, rvalue: &mut Rvalue<'tcx>) {
144127
if let Rvalue::Ref(_, _, place) | Rvalue::RawPtr(_, place) = rvalue {
145128
if let Some((base, ProjectionElem::Deref)) = place.as_ref().last_projection() {
146129
if rvalue.ty(self.local_decls, self.tcx) != base.ty(self.local_decls, self.tcx).ty {
147130
return;
148131
}
149132

150-
if !self.should_simplify(source_info, rvalue) {
151-
return;
152-
}
153-
154133
*rvalue = Rvalue::Use(Operand::Copy(Place {
155134
local: base.local,
156135
projection: self.tcx.mk_place_elems(base.projection),
@@ -160,36 +139,24 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
160139
}
161140

162141
/// Transform `Len([_; N])` ==> `N`.
163-
fn simplify_len(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
142+
fn simplify_len(&self, rvalue: &mut Rvalue<'tcx>) {
164143
if let Rvalue::Len(ref place) = *rvalue {
165144
let place_ty = place.ty(self.local_decls, self.tcx).ty;
166145
if let ty::Array(_, len) = *place_ty.kind() {
167-
if !self.should_simplify(source_info, rvalue) {
168-
return;
169-
}
170-
171146
let const_ = Const::from_ty_const(len, self.tcx.types.usize, self.tcx);
172-
let constant = ConstOperand { span: source_info.span, const_, user_ty: None };
147+
let constant = ConstOperand { span: DUMMY_SP, const_, user_ty: None };
173148
*rvalue = Rvalue::Use(Operand::Constant(Box::new(constant)));
174149
}
175150
}
176151
}
177152

178153
/// Transform `Aggregate(RawPtr, [p, ()])` ==> `Cast(PtrToPtr, p)`.
179-
fn simplify_ptr_aggregate(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
154+
fn simplify_ptr_aggregate(&self, rvalue: &mut Rvalue<'tcx>) {
180155
if let Rvalue::Aggregate(box AggregateKind::RawPtr(pointee_ty, mutability), fields) = rvalue
181156
{
182157
let meta_ty = fields.raw[1].ty(self.local_decls, self.tcx);
183158
if meta_ty.is_unit() {
184159
// The mutable borrows we're holding prevent printing `rvalue` here
185-
if !self.should_simplify_custom(
186-
source_info,
187-
"Aggregate::RawPtr",
188-
(&pointee_ty, *mutability, &fields),
189-
) {
190-
return;
191-
}
192-
193160
let mut fields = std::mem::take(fields);
194161
let _meta = fields.pop().unwrap();
195162
let data = fields.pop().unwrap();
@@ -199,10 +166,10 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
199166
}
200167
}
201168

202-
fn simplify_ub_check(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
169+
fn simplify_ub_check(&self, rvalue: &mut Rvalue<'tcx>) {
203170
if let Rvalue::NullaryOp(NullOp::UbChecks, _) = *rvalue {
204171
let const_ = Const::from_bool(self.tcx, self.tcx.sess.ub_checks());
205-
let constant = ConstOperand { span: source_info.span, const_, user_ty: None };
172+
let constant = ConstOperand { span: DUMMY_SP, const_, user_ty: None };
206173
*rvalue = Rvalue::Use(Operand::Constant(Box::new(constant)));
207174
}
208175
}
@@ -290,16 +257,6 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
290257
return;
291258
}
292259

293-
if !self.tcx.consider_optimizing(|| {
294-
format!(
295-
"InstSimplify - Call: {:?} SourceInfo: {:?}",
296-
(fn_def_id, fn_args),
297-
terminator.source_info
298-
)
299-
}) {
300-
return;
301-
}
302-
303260
let Ok([arg]) = take_array(args) else { return };
304261
let Some(arg_place) = arg.node.place() else { return };
305262

compiler/rustc_mir_transform/src/match_branches.rs

-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
2525
for i in 0..body.basic_blocks.len() {
2626
let bbs = &*body.basic_blocks;
2727
let bb_idx = BasicBlock::from_usize(i);
28-
if !tcx.consider_optimizing(|| format!("MatchBranchSimplification {def_id:?} ")) {
29-
continue;
30-
}
31-
3228
match bbs[bb_idx].terminator().kind {
3329
TerminatorKind::SwitchInt {
3430
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> 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> 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
@@ -46,10 +46,6 @@ impl<'tcx> MirPass<'tcx> for RenameReturnPlace {
4646
return;
4747
};
4848

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

compiler/rustc_mir_transform/src/remove_unneeded_drops.rs

-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops {
2626
if ty.ty.needs_drop(tcx, param_env) {
2727
continue;
2828
}
29-
if !tcx.consider_optimizing(|| format!("RemoveUnneededDrops {did:?} ")) {
30-
continue;
31-
}
3229
debug!("SUCCESS: replacing `drop` with goto({:?})", target);
3330
terminator.kind = TerminatorKind::Goto { target };
3431
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> 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 param_env = tcx.param_env_reveal_all_normalized(body.source.def_id());
2521
let local_decls = &body.local_decls;
2622
let mut replacer = Replacer { tcx, param_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
@@ -42,12 +42,6 @@ impl MirPass<'_> for UnreachablePropagation {
4242
}
4343
}
4444

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

5347
// 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
@@ -80,8 +80,6 @@ session_not_supported = not supported
8080
8181
session_octal_float_literal_not_supported = octal float literal is not supported
8282
83-
session_optimization_fuel_exhausted = optimization-fuel-exhausted: {$msg}
84-
8583
session_profile_sample_use_file_does_not_exist = file `{$path}` passed to `-C profile-sample-use` does not exist
8684
8785
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
@@ -2436,14 +2436,6 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
24362436
early_dcx.early_fatal("value for threads must be a positive non-zero integer");
24372437
}
24382438

2439-
let fuel = unstable_opts.fuel.is_some() || unstable_opts.print_fuel.is_some();
2440-
if fuel && unstable_opts.threads > 1 {
2441-
early_dcx.early_fatal("optimization fuel is incompatible with multiple threads");
2442-
}
2443-
if fuel && cg.incremental.is_some() {
2444-
early_dcx.early_fatal("optimization fuel is incompatible with incremental compilation");
2445-
}
2446-
24472439
let incremental = cg.incremental.as_ref().map(PathBuf::from);
24482440

24492441
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
@@ -447,12 +447,6 @@ pub fn report_lit_error(
447447
}
448448
}
449449

450-
#[derive(Diagnostic)]
451-
#[diag(session_optimization_fuel_exhausted)]
452-
pub(crate) struct OptimisationFuelExhausted {
453-
pub(crate) msg: String,
454-
}
455-
456450
#[derive(Diagnostic)]
457451
#[diag(session_incompatible_linker_flavor)]
458452
#[note]

0 commit comments

Comments
 (0)