Skip to content

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Sep 30, 2022

The CFG show output was not immediately obvious to me, so annotate it, and include statement ranges:

julia> # get some ir
       function foo(i)
           j = i+42
           j == 1 ? 1 : 2
       end

julia> ir = only(Base.code_ircode(foo, (Int,)))[1]
3 1%1 = Base.add_int(_2, 42)::Int64
4%2 = (%1 === 1)::Bool
  └──      goto #3 if not %2
  2return 1
  3return 2

julia> ir.cfg
1	=>	3, 2
2	=>
3	=>


julia> using Revise
julia> Revise.track(Base)

julia> ir.cfg
CFG with 3 blocks:
  bb 1 (stmts 1:3) ⇨ bb 3, 2
  bb 2 (stmt 4)
  bb 3 (stmt 5)

Feel free to bikeshed or give ideas on how to further improve the output.

@maleadt maleadt added the display and printing Aesthetics and correctness of printed representations of objects. label Sep 30, 2022
@gbaraldi
Copy link
Member

gbaraldi commented Oct 3, 2022

This looks cool but I think I prefer the old arrows instead of the unicode ones. Maybe use ⇨ instead of the thin one?

@maleadt maleadt force-pushed the tb/show_cfg branch 2 times, most recently from 38edc38 to eb4ba71 Compare October 4, 2022 12:02
@maleadt
Copy link
Member Author

maleadt commented Oct 4, 2022

looks pretty tiny in monospace font (see above).

@maleadt maleadt merged commit fe7f673 into master Oct 5, 2022
@maleadt maleadt deleted the tb/show_cfg branch October 5, 2022 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

display and printing Aesthetics and correctness of printed representations of objects.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants