Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 925a99f

Browse files
committed
refactor NLL MIR dump entry point
1 parent 15c146f commit 925a99f

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

‎compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ fn do_mir_borrowck<'tcx>(
229229

230230
// Dump MIR results into a file, if that is enabled. This let us
231231
// write unit-tests, as well as helping with debugging.
232-
nll::dump_mir_results(&infcx, body, &regioncx, &opt_closure_req);
232+
nll::dump_nll_mir(&infcx, body, &regioncx, &opt_closure_req);
233233

234234
// We also have a `#[rustc_regions]` annotation that causes us to dump
235235
// information.

‎compiler/rustc_borrowck/src/nll.rs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,23 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
210210
}
211211
}
212212

213-
pub(super) fn dump_mir_results<'tcx>(
213+
/// `-Zdump-mir=nll` dumps MIR annotated with NLL specific information:
214+
/// - free regions
215+
/// - inferred region values
216+
/// - region liveness
217+
/// - inference constraints and their causes
218+
///
219+
/// As well as graphviz `.dot` visualizations of:
220+
/// - the region constraints graph
221+
/// - the region SCC graph
222+
pub(super) fn dump_nll_mir<'tcx>(
214223
infcx: &BorrowckInferCtxt<'tcx>,
215224
body: &Body<'tcx>,
216225
regioncx: &RegionInferenceContext<'tcx>,
217226
closure_region_requirements: &Option<ClosureRegionRequirements<'tcx>>,
218227
) {
219-
if !dump_enabled(infcx.tcx, "nll", body.source.def_id()) {
228+
let tcx = infcx.tcx;
229+
if !dump_enabled(tcx, "nll", body.source.def_id()) {
220230
return;
221231
}
222232

@@ -230,7 +240,7 @@ pub(super) fn dump_mir_results<'tcx>(
230240
),
231241
};
232242
dump_mir_with_options(
233-
infcx.tcx,
243+
tcx,
234244
false,
235245
"nll",
236246
&0,
@@ -239,16 +249,14 @@ pub(super) fn dump_mir_results<'tcx>(
239249
match pass_where {
240250
// Before the CFG, dump out the values for each region variable.
241251
PassWhere::BeforeCFG => {
242-
regioncx.dump_mir(infcx.tcx, out)?;
252+
regioncx.dump_mir(tcx, out)?;
243253
writeln!(out, "|")?;
244254

245255
if let Some(closure_region_requirements) = closure_region_requirements {
246256
writeln!(out, "| Free Region Constraints")?;
247-
for_each_region_constraint(
248-
infcx.tcx,
249-
closure_region_requirements,
250-
&mut |msg| writeln!(out, "| {msg}"),
251-
)?;
257+
for_each_region_constraint(tcx, closure_region_requirements, &mut |msg| {
258+
writeln!(out, "| {msg}")
259+
})?;
252260
writeln!(out, "|")?;
253261
}
254262
}
@@ -264,15 +272,15 @@ pub(super) fn dump_mir_results<'tcx>(
264272
options,
265273
);
266274

267-
// Also dump the inference graph constraints as a graphviz file.
275+
// Also dump the region constraint graph as a graphviz file.
268276
let _: io::Result<()> = try {
269-
let mut file = create_dump_file(infcx.tcx, "regioncx.all.dot", false, "nll", &0, body)?;
277+
let mut file = create_dump_file(tcx, "regioncx.all.dot", false, "nll", &0, body)?;
270278
regioncx.dump_graphviz_raw_constraints(&mut file)?;
271279
};
272280

273-
// Also dump the inference graph constraints as a graphviz file.
281+
// Also dump the region constraint SCC graph as a graphviz file.
274282
let _: io::Result<()> = try {
275-
let mut file = create_dump_file(infcx.tcx, "regioncx.scc.dot", false, "nll", &0, body)?;
283+
let mut file = create_dump_file(tcx, "regioncx.scc.dot", false, "nll", &0, body)?;
276284
regioncx.dump_graphviz_scc_constraints(&mut file)?;
277285
};
278286
}

‎compiler/rustc_borrowck/src/region_infer/graphviz.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
4646
dot::render(&RawConstraints { regioncx: self }, &mut w)
4747
}
4848

49-
/// Write out the region constraint graph.
49+
/// Write out the region constraint SCC graph.
5050
pub(crate) fn dump_graphviz_scc_constraints(&self, mut w: &mut dyn Write) -> io::Result<()> {
5151
let mut nodes_per_scc: IndexVec<ConstraintSccIndex, _> =
5252
self.constraint_sccs.all_sccs().map(|_| Vec::new()).collect();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /