extract main NLL MIR dump function
this will allow calling from polonius MIR
This commit is contained in:
parent
e7fb93bf9b
commit
ee93ce9c61
2 changed files with 47 additions and 34 deletions
|
@ -232,6 +232,33 @@ pub(super) fn dump_nll_mir<'tcx>(
|
||||||
&0,
|
&0,
|
||||||
body,
|
body,
|
||||||
|pass_where, out| {
|
|pass_where, out| {
|
||||||
|
emit_nll_mir(tcx, regioncx, closure_region_requirements, borrow_set, pass_where, out)
|
||||||
|
},
|
||||||
|
options,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Also dump the region constraint graph as a graphviz file.
|
||||||
|
let _: io::Result<()> = try {
|
||||||
|
let mut file = create_dump_file(tcx, "regioncx.all.dot", false, "nll", &0, body)?;
|
||||||
|
regioncx.dump_graphviz_raw_constraints(&mut file)?;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Also dump the region constraint SCC graph as a graphviz file.
|
||||||
|
let _: io::Result<()> = try {
|
||||||
|
let mut file = create_dump_file(tcx, "regioncx.scc.dot", false, "nll", &0, body)?;
|
||||||
|
regioncx.dump_graphviz_scc_constraints(&mut file)?;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Produces the actual NLL MIR sections to emit during the dumping process.
|
||||||
|
pub(crate) fn emit_nll_mir<'tcx>(
|
||||||
|
tcx: TyCtxt<'tcx>,
|
||||||
|
regioncx: &RegionInferenceContext<'tcx>,
|
||||||
|
closure_region_requirements: &Option<ClosureRegionRequirements<'tcx>>,
|
||||||
|
borrow_set: &BorrowSet<'tcx>,
|
||||||
|
pass_where: PassWhere,
|
||||||
|
out: &mut dyn io::Write,
|
||||||
|
) -> io::Result<()> {
|
||||||
match pass_where {
|
match pass_where {
|
||||||
// Before the CFG, dump out the values for each region variable.
|
// Before the CFG, dump out the values for each region variable.
|
||||||
PassWhere::BeforeCFG => {
|
PassWhere::BeforeCFG => {
|
||||||
|
@ -266,21 +293,6 @@ pub(super) fn dump_nll_mir<'tcx>(
|
||||||
PassWhere::BeforeBlock(_) | PassWhere::AfterLocation(_) | PassWhere::AfterCFG => {}
|
PassWhere::BeforeBlock(_) | PassWhere::AfterLocation(_) | PassWhere::AfterCFG => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
|
||||||
options,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Also dump the region constraint graph as a graphviz file.
|
|
||||||
let _: io::Result<()> = try {
|
|
||||||
let mut file = create_dump_file(tcx, "regioncx.all.dot", false, "nll", &0, body)?;
|
|
||||||
regioncx.dump_graphviz_raw_constraints(&mut file)?;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Also dump the region constraint SCC graph as a graphviz file.
|
|
||||||
let _: io::Result<()> = try {
|
|
||||||
let mut file = create_dump_file(tcx, "regioncx.scc.dot", false, "nll", &0, body)?;
|
|
||||||
regioncx.dump_graphviz_scc_constraints(&mut file)?;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||||
|
|
|
@ -23,6 +23,7 @@ pub(crate) const ALIGN: usize = 40;
|
||||||
|
|
||||||
/// An indication of where we are in the control flow graph. Used for printing
|
/// An indication of where we are in the control flow graph. Used for printing
|
||||||
/// extra information in `dump_mir`
|
/// extra information in `dump_mir`
|
||||||
|
#[derive(Clone)]
|
||||||
pub enum PassWhere {
|
pub enum PassWhere {
|
||||||
/// We have not started dumping the control flow graph, but we are about to.
|
/// We have not started dumping the control flow graph, but we are about to.
|
||||||
BeforeCFG,
|
BeforeCFG,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue