|
98 | 98 |
|
99 | 99 | const preprinter_sentinel = isdefined(Base.IRShow, :statementidx_lineinfo_printer) ? 0 : typemin(Int32)
|
100 | 100 |
|
101 |
| -if isdefined(Base.IRShow, :show_ir_stmt) |
102 |
| - function print_with_code(preprint, postprint, io::IO, src::CodeInfo) |
103 |
| - src = copy(src) |
104 |
| - JuliaInterpreter.replace_coretypes!(src; rev=true) |
105 |
| - if isdefined(JuliaInterpreter, :reverse_lookup_globalref!) |
106 |
| - JuliaInterpreter.reverse_lookup_globalref!(src.code) |
107 |
| - end |
108 |
| - io = IOContext(io, :displaysize=>displaysize(io)) |
109 |
| - used = BitSet() |
110 |
| - cfg = Core.Compiler.compute_basic_blocks(src.code) |
111 |
| - for stmt in src.code |
112 |
| - Core.Compiler.scan_ssa_use!(push!, used, stmt) |
113 |
| - end |
114 |
| - line_info_preprinter = Base.IRShow.lineinfo_disabled |
115 |
| - line_info_postprinter = Base.IRShow.default_expr_type_printer |
116 |
| - preprint(io) |
117 |
| - bb_idx_prev = bb_idx = 1 |
118 |
| - for idx = 1:length(src.code) |
119 |
| - preprint(io, idx) |
120 |
| - bb_idx = Base.IRShow.show_ir_stmt(io, src, idx, line_info_preprinter, line_info_postprinter, used, cfg, bb_idx) |
121 |
| - postprint(io, idx, bb_idx != bb_idx_prev) |
122 |
| - bb_idx_prev = bb_idx |
123 |
| - end |
124 |
| - max_bb_idx_size = ndigits(length(cfg.blocks)) |
125 |
| - line_info_preprinter(io, " "^(max_bb_idx_size + 2), preprinter_sentinel) |
126 |
| - postprint(io) |
127 |
| - return nothing |
128 |
| - end |
129 |
| -else |
130 |
| - function print_with_code(preprint, postprint, io::IO, src::CodeInfo) |
131 |
| - println(io, "No IR statement printer available on this version of Julia, just aligning statements.") |
132 |
| - preprint(io) |
133 |
| - for idx = 1:length(src.code) |
134 |
| - preprint(io, idx) |
135 |
| - print(io, src.code[idx]) |
136 |
| - println(io) |
137 |
| - postprint(io, idx, false) |
138 |
| - end |
139 |
| - postprint(io) |
| 101 | +function print_with_code(preprint, postprint, io::IO, src::CodeInfo) |
| 102 | + src = copy(src) |
| 103 | + JuliaInterpreter.replace_coretypes!(src; rev=true) |
| 104 | + if isdefined(JuliaInterpreter, :reverse_lookup_globalref!) |
| 105 | + JuliaInterpreter.reverse_lookup_globalref!(src.code) |
| 106 | + end |
| 107 | + io = IOContext(io, :displaysize=>displaysize(io)) |
| 108 | + used = BitSet() |
| 109 | + cfg = Core.Compiler.compute_basic_blocks(src.code) |
| 110 | + for stmt in src.code |
| 111 | + Core.Compiler.scan_ssa_use!(push!, used, stmt) |
140 | 112 | end
|
| 113 | + line_info_preprinter = Base.IRShow.lineinfo_disabled |
| 114 | + line_info_postprinter = Base.IRShow.default_expr_type_printer |
| 115 | + preprint(io) |
| 116 | + bb_idx_prev = bb_idx = 1 |
| 117 | + for idx = 1:length(src.code) |
| 118 | + preprint(io, idx) |
| 119 | + bb_idx = Base.IRShow.show_ir_stmt(io, src, idx, line_info_preprinter, line_info_postprinter, used, cfg, bb_idx) |
| 120 | + postprint(io, idx, bb_idx != bb_idx_prev) |
| 121 | + bb_idx_prev = bb_idx |
| 122 | + end |
| 123 | + max_bb_idx_size = ndigits(length(cfg.blocks)) |
| 124 | + line_info_preprinter(io, " "^(max_bb_idx_size + 2), preprinter_sentinel) |
| 125 | + postprint(io) |
| 126 | + return nothing |
141 | 127 | end
|
142 | 128 |
|
143 | 129 | """
|
|
0 commit comments