Improve how the MIR dialect/phase index is reported.
The only visible change is to the filenames produce by `-Zdump-mir`. E.g. before and after: ``` h.main.003-000.analysis-post-cleanup.after.mir h.main.2-2-000.analysis-post-cleanup.after.mir ``` It also fixes a FIXME comment.
This commit is contained in:
parent
c039533656
commit
83a7fb61fb
3 changed files with 10 additions and 16 deletions
|
@ -99,20 +99,13 @@ impl<'tcx> HasLocalDecls<'tcx> for Body<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MirPhase {
|
impl MirPhase {
|
||||||
/// Gets the index of the current MirPhase within the set of all `MirPhase`s.
|
/// Gets the (dialect, phase) index of the current `MirPhase`. Both numbers
|
||||||
///
|
/// are 1-indexed.
|
||||||
/// FIXME(JakobDegen): Return a `(usize, usize)` instead.
|
pub fn index(&self) -> (usize, usize) {
|
||||||
pub fn phase_index(&self) -> usize {
|
match *self {
|
||||||
const BUILT_PHASE_COUNT: usize = 1;
|
MirPhase::Built => (1, 1),
|
||||||
const ANALYSIS_PHASE_COUNT: usize = 2;
|
MirPhase::Analysis(analysis_phase) => (2, 1 + analysis_phase as usize),
|
||||||
match self {
|
MirPhase::Runtime(runtime_phase) => (3, 1 + runtime_phase as usize),
|
||||||
MirPhase::Built => 1,
|
|
||||||
MirPhase::Analysis(analysis_phase) => {
|
|
||||||
1 + BUILT_PHASE_COUNT + (*analysis_phase as usize)
|
|
||||||
}
|
|
||||||
MirPhase::Runtime(runtime_phase) => {
|
|
||||||
1 + BUILT_PHASE_COUNT + ANALYSIS_PHASE_COUNT + (*runtime_phase as usize)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,8 @@ fn dump_path<'tcx>(
|
||||||
let pass_num = if tcx.sess.opts.unstable_opts.dump_mir_exclude_pass_number {
|
let pass_num = if tcx.sess.opts.unstable_opts.dump_mir_exclude_pass_number {
|
||||||
String::new()
|
String::new()
|
||||||
} else if pass_num {
|
} else if pass_num {
|
||||||
format!(".{:03}-{:03}", body.phase.phase_index(), body.pass_count)
|
let (dialect_index, phase_index) = body.phase.index();
|
||||||
|
format!(".{}-{}-{:03}", dialect_index, phase_index, body.pass_count)
|
||||||
} else {
|
} else {
|
||||||
".-------".to_string()
|
".-------".to_string()
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,7 +37,7 @@ use crate::ty::{self, GenericArgsRef, List, Region, Ty, UserTypeAnnotationIndex}
|
||||||
/// well-formed MIR, and subsequent phases mostly increase those restrictions. I.e. to convert MIR
|
/// well-formed MIR, and subsequent phases mostly increase those restrictions. I.e. to convert MIR
|
||||||
/// from one phase to the next might require removing/replacing certain MIR constructs.
|
/// from one phase to the next might require removing/replacing certain MIR constructs.
|
||||||
///
|
///
|
||||||
/// When adding dialects or phases, remember to update [`MirPhase::phase_index`].
|
/// When adding dialects or phases, remember to update [`MirPhase::index`].
|
||||||
#[derive(Copy, Clone, TyEncodable, TyDecodable, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Copy, Clone, TyEncodable, TyDecodable, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
#[derive(HashStable)]
|
#[derive(HashStable)]
|
||||||
pub enum MirPhase {
|
pub enum MirPhase {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue