@@ -40,77 +40,137 @@ use tracing::{debug, trace};
40
40
#[ macro_use]
41
41
mod pass_manager;
42
42
43
+ use std:: sync:: LazyLock ;
44
+
43
45
use pass_manager:: { self as pm, Lint , MirLint , MirPass , WithMinOptLevel } ;
44
46
45
- mod abort_unwinding_calls;
46
- mod add_call_guards;
47
- mod add_moves_for_packed_drops;
48
- mod add_retag;
49
- mod add_subtyping_projections;
50
- mod check_alignment;
51
- mod check_const_item_mutation;
52
- mod check_packed_ref;
53
- mod check_undefined_transmutes;
54
- // This pass is public to allow external drivers to perform MIR cleanup
55
- pub mod cleanup_post_borrowck;
56
- mod copy_prop;
57
- mod coroutine;
58
47
mod cost_checker;
59
- mod coverage;
60
48
mod cross_crate_inline;
61
- mod ctfe_limit;
62
- mod dataflow_const_prop;
63
- mod dead_store_elimination;
64
49
mod deduce_param_attrs;
65
- mod deduplicate_blocks;
66
- mod deref_separator;
67
- mod dest_prop;
68
- pub mod dump_mir;
69
- mod early_otherwise_branch;
70
- mod elaborate_box_derefs;
71
- mod elaborate_drops;
72
50
mod errors;
73
51
mod ffi_unwind_calls;
74
- mod function_item_references;
75
- mod gvn;
76
- // Made public so that `mir_drops_elaborated_and_const_checked` can be overridden
77
- // by custom rustc drivers, running all the steps by themselves. See #114628.
78
- pub mod inline;
79
- mod instsimplify;
80
- mod jump_threading;
81
- mod known_panics_lint;
82
- mod large_enums;
83
52
mod lint;
84
- mod lower_intrinsics;
85
- mod lower_slice_len;
86
- mod match_branches;
87
- mod mentioned_items;
88
- mod multiple_return_terminators;
89
- mod nrvo;
90
- mod post_drop_elaboration;
91
- mod prettify;
92
- mod promote_consts;
93
- mod ref_prop;
94
- mod remove_noop_landing_pads;
95
- mod remove_place_mention;
96
- mod remove_storage_markers;
97
- mod remove_uninit_drops;
98
- mod remove_unneeded_drops;
99
- mod remove_zsts;
100
- mod required_consts;
101
- mod reveal_all;
102
- mod sanity_check;
103
53
mod shim;
104
54
mod ssa;
105
- // This pass is public to allow external drivers to perform MIR cleanup
106
- pub mod simplify;
107
- mod simplify_branches;
108
- mod simplify_comparison_integral;
109
- mod single_use_consts;
110
- mod sroa;
111
- mod unreachable_enum_branching;
112
- mod unreachable_prop;
113
- mod validate;
55
+
56
+ macro_rules! declare_passes {
57
+ (
58
+ $(
59
+ $vis: vis mod $mod_name: ident : $( $pass_name: ident $( { $( $ident: ident) ,* } ) ?) ,+;
60
+ ) *
61
+ ) => {
62
+ $(
63
+ $vis mod $mod_name;
64
+ $(
65
+ // Make sure the type name is correct
66
+ #[ allow( unused_imports) ]
67
+ use $mod_name:: $pass_name as _;
68
+ ) +
69
+ ) *
70
+
71
+ #[ cfg( debug_assertions) ]
72
+ static PASS_NAMES : LazyLock <Vec <String >> = LazyLock :: new( || vec![
73
+ // Fake marker pass
74
+ "PreCodegen" . to_string( ) ,
75
+ $(
76
+ $(
77
+ stringify!( $pass_name) . to_string( ) ,
78
+ $(
79
+ $(
80
+ $mod_name:: $pass_name:: $ident. name( ) . to_string( ) ,
81
+ ) *
82
+ ) ?
83
+ ) +
84
+ ) *
85
+ ] ) ;
86
+ } ;
87
+ }
88
+
89
+ declare_passes ! {
90
+ mod abort_unwinding_calls : AbortUnwindingCalls ;
91
+ mod add_call_guards : AddCallGuards { AllCallEdges , CriticalCallEdges } ;
92
+ mod add_moves_for_packed_drops : AddMovesForPackedDrops ;
93
+ mod add_retag : AddRetag ;
94
+ mod add_subtyping_projections : Subtyper ;
95
+ mod check_alignment : CheckAlignment ;
96
+ mod check_const_item_mutation : CheckConstItemMutation ;
97
+ mod check_packed_ref : CheckPackedRef ;
98
+ mod check_undefined_transmutes : CheckUndefinedTransmutes ;
99
+ // This pass is public to allow external drivers to perform MIR cleanup
100
+ pub mod cleanup_post_borrowck : CleanupPostBorrowck ;
101
+
102
+ mod copy_prop : CopyProp ;
103
+ mod coroutine : StateTransform ;
104
+ mod coverage : InstrumentCoverage ;
105
+ mod ctfe_limit : CtfeLimit ;
106
+ mod dataflow_const_prop : DataflowConstProp ;
107
+ mod dead_store_elimination : DeadStoreElimination {
108
+ Initial ,
109
+ Final
110
+ } ;
111
+ mod deduplicate_blocks : DeduplicateBlocks ;
112
+ mod deref_separator : Derefer ;
113
+ mod dest_prop : DestinationPropagation ;
114
+ pub mod dump_mir : Marker ;
115
+ mod early_otherwise_branch : EarlyOtherwiseBranch ;
116
+ mod elaborate_box_derefs : ElaborateBoxDerefs ;
117
+ mod elaborate_drops : ElaborateDrops ;
118
+ mod function_item_references : FunctionItemReferences ;
119
+ mod gvn : GVN ;
120
+ // Made public so that `mir_drops_elaborated_and_const_checked` can be overridden
121
+ // by custom rustc drivers, running all the steps by themselves. See #114628.
122
+ pub mod inline : Inline ;
123
+ mod instsimplify : InstSimplify { BeforeInline , AfterSimplifyCfg } ;
124
+ mod jump_threading : JumpThreading ;
125
+ mod known_panics_lint : KnownPanicsLint ;
126
+ mod large_enums : EnumSizeOpt ;
127
+ mod lower_intrinsics : LowerIntrinsics ;
128
+ mod lower_slice_len : LowerSliceLenCalls ;
129
+ mod match_branches : MatchBranchSimplification ;
130
+ mod mentioned_items : MentionedItems ;
131
+ mod multiple_return_terminators : MultipleReturnTerminators ;
132
+ mod nrvo : RenameReturnPlace ;
133
+ mod post_drop_elaboration : CheckLiveDrops ;
134
+ mod prettify : ReorderBasicBlocks , ReorderLocals ;
135
+ mod promote_consts : PromoteTemps ;
136
+ mod ref_prop : ReferencePropagation ;
137
+ mod remove_noop_landing_pads : RemoveNoopLandingPads ;
138
+ mod remove_place_mention : RemovePlaceMention ;
139
+ mod remove_storage_markers : RemoveStorageMarkers ;
140
+ mod remove_uninit_drops : RemoveUninitDrops ;
141
+ mod remove_unneeded_drops : RemoveUnneededDrops ;
142
+ mod remove_zsts : RemoveZsts ;
143
+ mod required_consts : RequiredConstsVisitor ;
144
+ mod reveal_all : RevealAll ;
145
+ mod sanity_check : SanityCheck ;
146
+ // This pass is public to allow external drivers to perform MIR cleanup
147
+ pub mod simplify :
148
+ SimplifyCfg {
149
+ Initial ,
150
+ PromoteConsts ,
151
+ RemoveFalseEdges ,
152
+ PostAnalysis ,
153
+ PreOptimizations ,
154
+ Final ,
155
+ MakeShim ,
156
+ AfterUnreachableEnumBranching
157
+ } ,
158
+ SimplifyLocals {
159
+ BeforeConstProp ,
160
+ AfterGVN ,
161
+ Final
162
+ } ;
163
+ mod simplify_branches : SimplifyConstCondition {
164
+ AfterConstProp ,
165
+ Final
166
+ } ;
167
+ mod simplify_comparison_integral : SimplifyComparisonIntegral ;
168
+ mod single_use_consts : SingleUseConsts ;
169
+ mod sroa : ScalarReplacementOfAggregates ;
170
+ mod unreachable_enum_branching : UnreachableEnumBranching ;
171
+ mod unreachable_prop : UnreachablePropagation ;
172
+ mod validate : Validator ;
173
+ }
114
174
115
175
rustc_fluent_macro:: fluent_messages! { "../messages.ftl" }
116
176
0 commit comments