File tree Expand file tree Collapse file tree 2 files changed +29
-5
lines changed
compiler/rustc_mir/src/util Expand file tree Collapse file tree 2 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use gsgdt::GraphvizSettings;
22use rustc_graphviz as dot;
33use rustc_hir:: def_id:: DefId ;
44use rustc_middle:: mir:: * ;
5- use rustc_middle:: ty:: TyCtxt ;
5+ use rustc_middle:: ty:: { self , TyCtxt } ;
66use std:: fmt:: Debug ;
77use std:: io:: { self , Write } ;
88
@@ -16,14 +16,27 @@ where
1616{
1717 let def_ids = dump_mir_def_ids ( tcx, single) ;
1818
19- let use_subgraphs = def_ids. len ( ) > 1 ;
19+ let mirs =
20+ def_ids
21+ . iter ( )
22+ . flat_map ( |def_id| {
23+ if tcx. is_const_fn_raw ( * def_id) {
24+ vec ! [ tcx. optimized_mir( * def_id) , tcx. mir_for_ctfe( * def_id) ]
25+ } else {
26+ vec ! [ tcx. instance_mir( ty:: InstanceDef :: Item ( ty:: WithOptConstParam :: unknown(
27+ * def_id,
28+ ) ) ) ]
29+ }
30+ } )
31+ . collect :: < Vec < _ > > ( ) ;
32+
33+ let use_subgraphs = mirs. len ( ) > 1 ;
2034 if use_subgraphs {
2135 writeln ! ( w, "digraph __crate__ {{" ) ?;
2236 }
2337
24- for def_id in def_ids {
25- let body = & tcx. optimized_mir ( def_id) ;
26- write_mir_fn_graphviz ( tcx, body, use_subgraphs, w) ?;
38+ for mir in mirs {
39+ write_mir_fn_graphviz ( tcx, mir, use_subgraphs, w) ?;
2740 }
2841
2942 if use_subgraphs {
Original file line number Diff line number Diff line change 1+ // check-pass
2+ // dont-check-compiler-stdout
3+ // compile-flags: -Z unpretty=mir-cfg
4+
5+ // This checks that unpretty=mir-cfg does not panic. See #81918.
6+
7+ const TAG : & ' static str = "ABCD" ;
8+
9+ fn main ( ) {
10+ if TAG == "" { }
11+ }
You can’t perform that action at this time.
0 commit comments