@@ -12,15 +12,25 @@ use crate::MonoItemKind;
1212
1313use crate :: mk_graph:: context:: GraphContext ;
1414use crate :: mk_graph:: util:: { block_name, is_unqualified, name_lines, short_name, GraphLabelString } ;
15+ use crate :: mk_graph:: { compute_lang_start_exclusions, skip_lang_start} ;
1516
1617impl SmirJson < ' _ > {
1718 /// Convert the MIR to DOT (Graphviz) format
18- pub fn to_dot_file ( self ) -> String {
19+ pub fn to_dot_file ( mut self ) -> String {
1920 let mut bytes = Vec :: new ( ) ;
2021
2122 // Build context BEFORE consuming self
2223 let ctx = GraphContext :: from_smir ( & self ) ;
2324
25+ // Optionally filter out lang_start items and their unique descendants
26+ let excluded: HashSet < String > = if skip_lang_start ( ) {
27+ let excluded = compute_lang_start_exclusions ( & self . items , & ctx) ;
28+ self . items . retain ( |i| !excluded. contains ( & i. symbol_name ) ) ;
29+ excluded
30+ } else {
31+ HashSet :: new ( )
32+ } ;
33+
2434 {
2535 let mut writer = DotWriter :: from ( & mut bytes) ;
2636
@@ -57,7 +67,7 @@ impl SmirJson<'_> {
5767
5868 // first create all nodes for functions not in the items list
5969 for f in ctx. functions . values ( ) {
60- if !item_names. contains ( f) {
70+ if !item_names. contains ( f) && !excluded . contains ( f ) {
6171 graph
6272 . node_named ( block_name ( f, 0 ) )
6373 . set_label ( & name_lines ( f) )
@@ -245,6 +255,20 @@ impl SmirJson<'_> {
245255
246256 match & b. terminator . kind {
247257 TerminatorKind :: Call { func, args, .. } => {
258+ // Skip call edges to excluded nodes
259+ if let Operand :: Constant ( ConstOperand {
260+ const_, ..
261+ } ) = func
262+ {
263+ if ctx
264+ . functions
265+ . get ( & const_. ty ( ) )
266+ . is_some_and ( |c| excluded. contains ( c) )
267+ {
268+ continue ;
269+ }
270+ }
271+
248272 let e = match func {
249273 Operand :: Constant ( ConstOperand {
250274 const_, ..
0 commit comments