@@ -4,7 +4,7 @@ using MacroTools: isexpr, prewalk
44
55using .. Inner, .. IRTools
66import .. Inner: IR, Variable, Statement, Branch, BasicBlock, Meta, block!,
7- unreachable, varmap, argument!, branch!, return !
7+ unreachable, varmap, argument!, branch!, return !, LineInfoNode
88import Core: CodeInfo, GotoNode, SSAValue
99import Core. Compiler: IRCode, CFG, GotoIfNot, ReturnNode, StmtRange
1010
@@ -108,7 +108,9 @@ function IRCode(ir::IR)
108108 debuginfo. linetable = Core. DebugInfo (debuginfo. def, nothing , Core. svec (), codelocs)
109109 IRCode (stmts, cfg, debuginfo, ir. blocks[1 ]. argtypes, meta, sps)
110110 else
111- IRCode (stmts, cfg, ir. lines, ir. blocks[1 ]. argtypes, meta, sps)
111+ mod, meth = ir. meta isa Meta ? (ir. meta. method. module, ir. meta. method) : (Main, nothing )
112+ linetable = map (li -> Core. LineInfoNode (mod, meth, li. file, li. line, li. inlined_at), ir. lines)
113+ IRCode (stmts, cfg, linetable, ir. blocks[1 ]. argtypes, meta, sps)
112114 end
113115 else
114116 IRCode (stmts, types, lines, flags, cfg, ir. lines, ir. blocks[1 ]. argtypes, [], sps)
@@ -159,20 +161,21 @@ function IR(ci::CodeInfo, nargs::Integer; meta = nothing)
159161 def = isnothing (meta) ? :var"n/a" : meta. instance
160162 N = length (ci. code)
161163 codelocs = fill (0 , N)
162- linetable = Base . IRShow . LineInfoNode[]
164+ linetable = LineInfoNode[]
163165
164166 # NOTE: we could be faster about decoding here and support inlining?
165167 for pc in 1 : N
166168 LI = Base. IRShow. buildLineInfoNode (ci. debuginfo, def, pc)
167169 if ! isempty (LI)
168- push! (linetable, first (LI))
170+ linode = first (LI) # ::Base.IRShow.LineInfoNode
171+ push! (linetable, LineInfoNode (linode. file, linode. line))
169172 codelocs[pc] = length (linetable)
170173 end
171174 end
172175
173176 codelocs, linetable
174177 else
175- ci. codelocs, Core . LineInfoNode[ci . linetable ... ]
178+ ci. codelocs, map (li -> LineInfoNode (li . file, li . line), ci . linetable)
176179 end
177180 ir = IR (linetable, meta = meta)
178181 _rename = Dict ()
0 commit comments