This repository was archived by the owner on May 28, 2025. It is now read-only.
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;
2
2
use rustc_graphviz as dot;
3
3
use rustc_hir:: def_id:: DefId ;
4
4
use rustc_middle:: mir:: * ;
5
- use rustc_middle:: ty:: TyCtxt ;
5
+ use rustc_middle:: ty:: { self , TyCtxt } ;
6
6
use std:: fmt:: Debug ;
7
7
use std:: io:: { self , Write } ;
8
8
@@ -16,14 +16,27 @@ where
16
16
{
17
17
let def_ids = dump_mir_def_ids ( tcx, single) ;
18
18
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 ;
20
34
if use_subgraphs {
21
35
writeln ! ( w, "digraph __crate__ {{" ) ?;
22
36
}
23
37
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) ?;
27
40
}
28
41
29
42
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