Skip to content

Commit 7a6832d

Browse files
committed
change MIR dump filenames from nodeN to DefPath
1 parent fd9ecfd commit 7a6832d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+155
-132
lines changed

src/librustc/hir/map/definitions.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,26 @@ impl DefPath {
314314

315315
s
316316
}
317+
318+
/// Return filename friendly string of the DefPah without
319+
/// the crate-prefix. This method is useful if you don't have
320+
/// a TyCtxt available.
321+
pub fn to_filename_friendly_no_crate(&self) -> String {
322+
let mut s = String::with_capacity(self.data.len() * 16);
323+
324+
for component in &self.data {
325+
if component.disambiguator == 0 {
326+
write!(s, ".{}", component.data.as_interned_str()).unwrap();
327+
} else {
328+
write!(s,
329+
".{}[{}]",
330+
component.data.as_interned_str(),
331+
component.disambiguator)
332+
.unwrap();
333+
}
334+
}
335+
s
336+
}
317337
}
318338

319339
#[derive(Clone, Debug, Eq, PartialEq, Hash, RustcEncodable, RustcDecodable)]

src/librustc_mir/util/pretty.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,12 @@ where
132132
let p = Path::new(file_dir);
133133
file_path.push(p);
134134
};
135+
135136
let _ = fs::create_dir_all(&file_path);
136-
let file_name = format!("rustc.node{}{}{}.{}.{}.mir",
137-
source.item_id(), promotion_id, pass_num, pass_name, disambiguator);
137+
let function_name = tcx.hir.def_path_from_id(source.item_id())
138+
.map(|d| d.to_filename_friendly_no_crate()) .unwrap_or(format!(".node{}", source.item_id()));
139+
let file_name = format!("rustc{}{}{}.{}.{}.mir",
140+
function_name, promotion_id, pass_num, pass_name, disambiguator);
138141
file_path.push(&file_name);
139142
let _ = fs::File::create(&file_path).and_then(|mut file| {
140143
writeln!(file, "// MIR for `{}`", node_path)?;

src/test/mir-opt/basic_assignment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() {
3636
}
3737

3838
// END RUST SOURCE
39-
// START rustc.node4.SimplifyCfg-initial.after.mir
39+
// START rustc.main.SimplifyCfg-initial.after.mir
4040
// bb0: {
4141
// StorageLive(_1);
4242
// _1 = const false;
@@ -82,4 +82,4 @@ fn main() {
8282
// StorageDead(_1);
8383
// return;
8484
// }
85-
// END rustc.node4.SimplifyCfg-initial.after.mir
85+
// END rustc.main.SimplifyCfg-initial.after.mir

src/test/mir-opt/box_expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl Drop for S {
2828
}
2929

3030
// END RUST SOURCE
31-
// START rustc.node4.ElaborateDrops.before.mir
31+
// START rustc.main.ElaborateDrops.before.mir
3232
// let mut _0: ();
3333
// scope 1 {
3434
// let _1: std::boxed::Box<S>;
@@ -88,4 +88,4 @@ impl Drop for S {
8888
// return;
8989
// }
9090
// }
91-
// END rustc.node4.ElaborateDrops.before.mir
91+
// END rustc.main.ElaborateDrops.before.mir

src/test/mir-opt/copy_propagation.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
}
2020

2121
// END RUST SOURCE
22-
// START rustc.node4.CopyPropagation.before.mir
22+
// START rustc.test.CopyPropagation.before.mir
2323
// bb0: {
2424
// ...
2525
// _3 = _1;
@@ -31,12 +31,12 @@ fn main() {
3131
// ...
3232
// return;
3333
// }
34-
// END rustc.node4.CopyPropagation.before.mir
35-
// START rustc.node4.CopyPropagation.after.mir
34+
// END rustc.test.CopyPropagation.before.mir
35+
// START rustc.test.CopyPropagation.after.mir
3636
// bb0: {
3737
// ...
3838
// _0 = _1;
3939
// ...
4040
// return;
4141
// }
42-
// END rustc.node4.CopyPropagation.after.mir
42+
// END rustc.test.CopyPropagation.after.mir

src/test/mir-opt/deaggregator_test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() {
2424
}
2525

2626
// END RUST SOURCE
27-
// START rustc.node13.Deaggregator.before.mir
27+
// START rustc.bar.Deaggregator.before.mir
2828
// bb0: {
2929
// ...
3030
// _2 = _1;
@@ -33,8 +33,8 @@ fn main() {
3333
// ...
3434
// return;
3535
// }
36-
// END rustc.node13.Deaggregator.before.mir
37-
// START rustc.node13.Deaggregator.after.mir
36+
// END rustc.bar.Deaggregator.before.mir
37+
// START rustc.bar.Deaggregator.after.mir
3838
// bb0: {
3939
// ...
4040
// _2 = _1;
@@ -45,4 +45,4 @@ fn main() {
4545
// ...
4646
// return;
4747
// }
48-
// END rustc.node13.Deaggregator.after.mir
48+
// END rustc.bar.Deaggregator.after.mir

src/test/mir-opt/deaggregator_test_enum.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ fn main() {
2626
}
2727

2828
// END RUST SOURCE
29-
// START rustc.node10.Deaggregator.before.mir
29+
// START rustc.bar.Deaggregator.before.mir
3030
// bb0: {
3131
// StorageLive(_2);
3232
// _2 = _1;
3333
// _0 = Baz::Foo { x: _2 };
3434
// StorageDead(_2);
3535
// return;
3636
// }
37-
// END rustc.node10.Deaggregator.before.mir
38-
// START rustc.node10.Deaggregator.after.mir
37+
// END rustc.bar.Deaggregator.before.mir
38+
// START rustc.bar.Deaggregator.after.mir
3939
// bb0: {
4040
// StorageLive(_2);
4141
// _2 = _1;
@@ -44,4 +44,4 @@ fn main() {
4444
// StorageDead(_2);
4545
// return;
4646
// }
47-
// END rustc.node10.Deaggregator.after.mir
47+
// END rustc.bar.Deaggregator.after.mir

src/test/mir-opt/deaggregator_test_enum_2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() {
2929
}
3030

3131
// END RUST SOURCE
32-
// START rustc.node12.Deaggregator.before.mir
32+
// START rustc.test1.Deaggregator.before.mir
3333
// bb1: {
3434
// StorageLive(_4);
3535
// _4 = _2;
@@ -44,8 +44,8 @@ fn main() {
4444
// StorageDead(_5);
4545
// goto -> bb3;
4646
// }
47-
// END rustc.node12.Deaggregator.before.mir
48-
// START rustc.node12.Deaggregator.after.mir
47+
// END rustc.test1.Deaggregator.before.mir
48+
// START rustc.test1.Deaggregator.after.mir
4949
// bb1: {
5050
// StorageLive(_4);
5151
// _4 = _2;
@@ -62,5 +62,5 @@ fn main() {
6262
// StorageDead(_5);
6363
// goto -> bb3;
6464
// }
65-
// END rustc.node12.Deaggregator.after.mir
65+
// END rustc.test1.Deaggregator.after.mir
6666
//

src/test/mir-opt/deaggregator_test_multiple.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn main() {
2525
}
2626

2727
// END RUST SOURCE
28-
// START rustc.node10.Deaggregator.before.mir
28+
// START rustc.test.Deaggregator.before.mir
2929
// bb0: {
3030
// ...
3131
// _3 = _1;
@@ -39,8 +39,8 @@ fn main() {
3939
// ...
4040
// return;
4141
// }
42-
// END rustc.node10.Deaggregator.before.mir
43-
// START rustc.node10.Deaggregator.after.mir
42+
// END rustc.test.Deaggregator.before.mir
43+
// START rustc.test.Deaggregator.after.mir
4444
// bb0: {
4545
// ...
4646
// _3 = _1;
@@ -56,4 +56,4 @@ fn main() {
5656
// ...
5757
// return;
5858
// }
59-
// END rustc.node10.Deaggregator.after.mir
59+
// END rustc.test.Deaggregator.after.mir

src/test/mir-opt/end_region_1.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
}
2020

2121
// END RUST SOURCE
22-
// START rustc.node4.SimplifyCfg-qualify-consts.after.mir
22+
// START rustc.main.SimplifyCfg-qualify-consts.after.mir
2323
// let mut _0: ();
2424
// ...
2525
// let _1: i32;
@@ -37,4 +37,4 @@ fn main() {
3737
// StorageDead(_1);
3838
// return;
3939
// }
40-
// END rustc.node4.SimplifyCfg-qualify-consts.after.mir
40+
// END rustc.main.SimplifyCfg-qualify-consts.after.mir

0 commit comments

Comments
 (0)