Skip to content

Commit 826dca2

Browse files
committed
Disable non-required MIR opts with optimize(none)
1 parent b739645 commit 826dca2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+352
-75
lines changed

compiler/rustc_attr/src/builtin.rs

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ pub enum OptimizeAttr {
6363
Size,
6464
}
6565

66+
impl OptimizeAttr {
67+
pub fn do_not_optimize(&self) -> bool {
68+
matches!(self, Self::None)
69+
}
70+
}
71+
6672
/// Represents the following attributes:
6773
///
6874
/// - `#[stable]`

compiler/rustc_mir_transform/src/abort_unwinding_calls.rs

+4
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,8 @@ impl<'tcx> crate::MirPass<'tcx> for AbortUnwindingCalls {
116116
// We may have invalidated some `cleanup` blocks so clean those up now.
117117
super::simplify::remove_dead_blocks(body);
118118
}
119+
120+
fn is_required(&self) -> bool {
121+
true
122+
}
119123
}

compiler/rustc_mir_transform/src/add_call_guards.rs

+4
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,8 @@ impl<'tcx> crate::MirPass<'tcx> for AddCallGuards {
7575

7676
body.basic_blocks_mut().extend(new_blocks);
7777
}
78+
79+
fn is_required(&self) -> bool {
80+
true
81+
}
7882
}

compiler/rustc_mir_transform/src/add_moves_for_packed_drops.rs

+4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ impl<'tcx> crate::MirPass<'tcx> for AddMovesForPackedDrops {
6868

6969
patch.apply(body);
7070
}
71+
72+
fn is_required(&self) -> bool {
73+
true
74+
}
7175
}
7276

7377
fn add_move_for_packed_drop<'tcx>(

compiler/rustc_mir_transform/src/add_retag.rs

+4
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,8 @@ impl<'tcx> crate::MirPass<'tcx> for AddRetag {
176176
}
177177
}
178178
}
179+
180+
fn is_required(&self) -> bool {
181+
true
182+
}
179183
}

compiler/rustc_mir_transform/src/add_subtyping_projections.rs

+4
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,8 @@ impl<'tcx> crate::MirPass<'tcx> for Subtyper {
6161
}
6262
checker.patcher.apply(body);
6363
}
64+
65+
fn is_required(&self) -> bool {
66+
true
67+
}
6468
}

compiler/rustc_mir_transform/src/check_alignment.rs

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ impl<'tcx> crate::MirPass<'tcx> for CheckAlignment {
6060
}
6161
}
6262
}
63+
64+
fn is_required(&self) -> bool {
65+
true
66+
}
6367
}
6468

6569
struct PointerFinder<'a, 'tcx> {

compiler/rustc_mir_transform/src/cleanup_post_borrowck.rs

+4
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,8 @@ impl<'tcx> crate::MirPass<'tcx> for CleanupPostBorrowck {
7272
decl.user_ty = None;
7373
}
7474
}
75+
76+
fn is_required(&self) -> bool {
77+
true
78+
}
7579
}

compiler/rustc_mir_transform/src/copy_prop.rs

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp {
5656
crate::simplify::remove_unused_definitions(body);
5757
}
5858
}
59+
60+
fn is_required(&self) -> bool {
61+
false
62+
}
5963
}
6064

6165
/// `SsaLocals` computed equivalence classes between locals considering copy/move assignments.

compiler/rustc_mir_transform/src/coroutine.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,10 @@ impl<'tcx> crate::MirPass<'tcx> for StateTransform {
16891689
// Run derefer to fix Derefs that are not in the first place
16901690
deref_finder(tcx, body);
16911691
}
1692+
1693+
fn is_required(&self) -> bool {
1694+
true
1695+
}
16921696
}
16931697

16941698
/// Looks for any assignments between locals (e.g., `_4 = _5`) that will both be converted to fields

compiler/rustc_mir_transform/src/coverage/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ impl<'tcx> crate::MirPass<'tcx> for InstrumentCoverage {
6565

6666
instrument_function_for_coverage(tcx, mir_body);
6767
}
68+
69+
fn is_required(&self) -> bool {
70+
false
71+
}
6872
}
6973

7074
fn instrument_function_for_coverage<'tcx>(tcx: TyCtxt<'tcx>, mir_body: &mut mir::Body<'tcx>) {

compiler/rustc_mir_transform/src/cross_crate_inline.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
6969
// Don't do any inference if codegen optimizations are disabled and also MIR inlining is not
7070
// enabled. This ensures that we do inference even if someone only passes -Zinline-mir,
7171
// which is less confusing than having to also enable -Copt-level=1.
72-
if matches!(tcx.sess.opts.optimize, OptLevel::No) && !pm::should_run_pass(tcx, &inline::Inline)
72+
if matches!(tcx.sess.opts.optimize, OptLevel::No)
73+
&& !pm::should_run_pass(tcx, &inline::Inline, false)
7374
{
7475
return false;
7576
}

compiler/rustc_mir_transform/src/ctfe_limit.rs

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ impl<'tcx> crate::MirPass<'tcx> for CtfeLimit {
3636
);
3737
}
3838
}
39+
40+
fn is_required(&self) -> bool {
41+
true
42+
}
3943
}
4044

4145
fn has_back_edge(

compiler/rustc_mir_transform/src/dataflow_const_prop.rs

+4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ impl<'tcx> crate::MirPass<'tcx> for DataflowConstProp {
7171
let mut patch = visitor.patch;
7272
debug_span!("patch").in_scope(|| patch.visit_body_preserves_cfg(body));
7373
}
74+
75+
fn is_required(&self) -> bool {
76+
false
77+
}
7478
}
7579

7680
// Note: Currently, places that have their reference taken cannot be tracked. Although this would

compiler/rustc_mir_transform/src/dead_store_elimination.rs

+4
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,8 @@ impl<'tcx> crate::MirPass<'tcx> for DeadStoreElimination {
147147
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
148148
eliminate(tcx, body);
149149
}
150+
151+
fn is_required(&self) -> bool {
152+
false
153+
}
150154
}

compiler/rustc_mir_transform/src/deduplicate_blocks.rs

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ impl<'tcx> crate::MirPass<'tcx> for DeduplicateBlocks {
3131
simplify_cfg(body);
3232
}
3333
}
34+
35+
fn is_required(&self) -> bool {
36+
false
37+
}
3438
}
3539

3640
struct OptApplier<'tcx> {

compiler/rustc_mir_transform/src/deref_separator.rs

+4
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,8 @@ impl<'tcx> crate::MirPass<'tcx> for Derefer {
8181
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
8282
deref_finder(tcx, body);
8383
}
84+
85+
fn is_required(&self) -> bool {
86+
true
87+
}
8488
}

compiler/rustc_mir_transform/src/dest_prop.rs

+4
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation {
239239

240240
trace!(round_count);
241241
}
242+
243+
fn is_required(&self) -> bool {
244+
false
245+
}
242246
}
243247

244248
#[derive(Debug, Default)]

compiler/rustc_mir_transform/src/dump_mir.rs

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ impl<'tcx> crate::MirPass<'tcx> for Marker {
1515
}
1616

1717
fn run_pass(&self, _tcx: TyCtxt<'tcx>, _body: &mut Body<'tcx>) {}
18+
19+
fn is_required(&self) -> bool {
20+
false
21+
}
1822
}
1923

2024
pub fn emit_mir(tcx: TyCtxt<'_>) -> io::Result<()> {

compiler/rustc_mir_transform/src/early_otherwise_branch.rs

+4
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ impl<'tcx> crate::MirPass<'tcx> for EarlyOtherwiseBranch {
210210
simplify_cfg(body);
211211
}
212212
}
213+
214+
fn is_required(&self) -> bool {
215+
false
216+
}
213217
}
214218

215219
#[derive(Debug)]

compiler/rustc_mir_transform/src/elaborate_box_derefs.rs

+4
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,8 @@ impl<'tcx> crate::MirPass<'tcx> for ElaborateBoxDerefs {
149149
}
150150
}
151151
}
152+
153+
fn is_required(&self) -> bool {
154+
true
155+
}
152156
}

compiler/rustc_mir_transform/src/elaborate_drops.rs

+4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ impl<'tcx> crate::MirPass<'tcx> for ElaborateDrops {
8888
elaborate_patch.apply(body);
8989
deref_finder(tcx, body);
9090
}
91+
92+
fn is_required(&self) -> bool {
93+
true
94+
}
9195
}
9296

9397
/// Records unwind edges which are known to be unreachable, because they are in `drop` terminators

compiler/rustc_mir_transform/src/gvn.rs

+4
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ impl<'tcx> crate::MirPass<'tcx> for GVN {
163163
// statements.
164164
StorageRemover { tcx, reused_locals: state.reused_locals }.visit_body_preserves_cfg(body);
165165
}
166+
167+
fn is_required(&self) -> bool {
168+
false
169+
}
166170
}
167171

168172
newtype_index! {

compiler/rustc_mir_transform/src/inline.rs

+4
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ impl<'tcx> crate::MirPass<'tcx> for Inline {
7373
deref_finder(tcx, body);
7474
}
7575
}
76+
77+
fn is_required(&self) -> bool {
78+
false
79+
}
7680
}
7781

7882
fn inline<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) -> bool {

compiler/rustc_mir_transform/src/instsimplify.rs

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ impl<'tcx> crate::MirPass<'tcx> for InstSimplify {
6161
simplify_duplicate_switch_targets(block.terminator.as_mut().unwrap());
6262
}
6363
}
64+
65+
fn is_required(&self) -> bool {
66+
false
67+
}
6468
}
6569

6670
struct InstSimplifyContext<'a, 'tcx> {

compiler/rustc_mir_transform/src/jump_threading.rs

+4
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ impl<'tcx> crate::MirPass<'tcx> for JumpThreading {
106106
}
107107
OpportunitySet::new(body, opportunities).apply(body);
108108
}
109+
110+
fn is_required(&self) -> bool {
111+
false
112+
}
109113
}
110114

111115
#[derive(Debug)]

compiler/rustc_mir_transform/src/large_enums.rs

+4
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ impl<'tcx> crate::MirPass<'tcx> for EnumSizeOpt {
200200
});
201201
}
202202
}
203+
204+
fn is_required(&self) -> bool {
205+
false
206+
}
203207
}
204208

205209
impl EnumSizeOpt {

0 commit comments

Comments
 (0)