Improve how the MIR dialect/phase index is reported. · rust-lang/rust@83a7fb6 (original) (raw)
3 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -99,20 +99,13 @@ impl<'tcx> HasLocalDecls<'tcx> for Body<'tcx> { | ||
99 | 99 | } |
100 | 100 | |
101 | 101 | impl MirPhase { |
102 | -/// Gets the index of the current MirPhase within the set of all `MirPhase`s. | |
103 | - /// | |
104 | - /// FIXME(JakobDegen): Return a `(usize, usize)` instead. | |
105 | - pub fn phase_index(&self) -> usize { | |
106 | -const BUILT_PHASE_COUNT: usize = 1; | |
107 | -const ANALYSIS_PHASE_COUNT: usize = 2; | |
108 | -match self { | |
109 | -MirPhase::Built => 1, | |
110 | -MirPhase::Analysis(analysis_phase) => { | |
111 | -1 + BUILT_PHASE_COUNT + (*analysis_phase as usize) | |
112 | -} | |
113 | -MirPhase::Runtime(runtime_phase) => { | |
114 | -1 + BUILT_PHASE_COUNT + ANALYSIS_PHASE_COUNT + (*runtime_phase as usize) | |
115 | -} | |
102 | +/// Gets the (dialect, phase) index of the current `MirPhase`. Both numbers | |
103 | + /// are 1-indexed. | |
104 | + pub fn index(&self) -> (usize, usize) { | |
105 | +match *self { | |
106 | +MirPhase::Built => (1, 1), | |
107 | +MirPhase::Analysis(analysis_phase) => (2, 1 + analysis_phase as usize), | |
108 | +MirPhase::Runtime(runtime_phase) => (3, 1 + runtime_phase as usize), | |
116 | 109 | } |
117 | 110 | } |
118 | 111 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -231,7 +231,8 @@ fn dump_path<'tcx>( | ||
231 | 231 | let pass_num = if tcx.sess.opts.unstable_opts.dump_mir_exclude_pass_number { |
232 | 232 | String::new() |
233 | 233 | } else if pass_num { |
234 | -format!(".{:03}-{:03}", body.phase.phase_index(), body.pass_count) | |
234 | +let (dialect_index, phase_index) = body.phase.index(); | |
235 | +format!(".{}-{}-{:03}", dialect_index, phase_index, body.pass_count) | |
235 | 236 | } else { |
236 | 237 | ".-------".to_string() |
237 | 238 | }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -37,7 +37,7 @@ use crate::ty::{self, GenericArgsRef, List, Region, Ty, UserTypeAnnotationIndex} | ||
37 | 37 | /// well-formed MIR, and subsequent phases mostly increase those restrictions. I.e. to convert MIR |
38 | 38 | /// from one phase to the next might require removing/replacing certain MIR constructs. |
39 | 39 | /// |
40 | -/// When adding dialects or phases, remember to update [`MirPhase::phase_index`]. | |
40 | +/// When adding dialects or phases, remember to update [`MirPhase::index`]. | |
41 | 41 | #[derive(Copy, Clone, TyEncodable, TyDecodable, Debug, PartialEq, Eq, PartialOrd, Ord)] |
42 | 42 | #[derive(HashStable)] |
43 | 43 | pub enum MirPhase { |