@@ -304,30 +304,47 @@ function ir_inline_item!(compact::IncrementalCompact, idx::Int, argexprs::Vector
304304 boundscheck:: Symbol , todo_bbs:: Vector{Tuple{Int, Int}} )
305305 # Ok, do the inlining here
306306 spec = item. spec:: ResolvedInliningSpec
307+ sparam_vals = item. mi. sparam_vals
308+ def = item. mi. def:: Method
307309 inline_cfg = spec. ir. cfg
308310 stmt = compact. result[idx][:inst ]
309311 linetable_offset:: Int32 = length (linetable)
310312 # Append the linetable of the inlined function to our line table
311313 inlined_at = Int (compact. result[idx][:line ])
312- for entry in spec. ir. linetable
313- push! (linetable, LineInfoNode (entry. module, entry. method, entry. file, entry. line,
314- (entry. inlined_at > 0 ? entry. inlined_at + linetable_offset : inlined_at)))
314+ topline:: Int32 = linetable_offset + Int32 (1 )
315+ coverage = coverage_enabled (def. module)
316+ push! (linetable, LineInfoNode (def. module, def. name, def. file, Int (def. line), inlined_at))
317+ oldlinetable = spec. ir. linetable
318+ for oldline in 1 : length (oldlinetable)
319+ entry = oldlinetable[oldline]
320+ newentry = LineInfoNode (entry. module, entry. method, entry. file, entry. line,
321+ (entry. inlined_at > 0 ? entry. inlined_at + linetable_offset + (oldline == 1 ) : inlined_at))
322+ if oldline == 1
323+ # check for a duplicate on the first iteration (likely true)
324+ if newentry === linetable[topline]
325+ continue
326+ else
327+ linetable_offset += 1
328+ end
329+ end
330+ push! (linetable, newentry)
331+ end
332+ if coverage && spec. ir. stmts[1 ][:line ] + linetable_offset != topline
333+ insert_node_here! (compact, NewInstruction (Expr (:code_coverage_effect ), Nothing, topline))
315334 end
316- (; def, sparam_vals) = item. mi
317335 nargs_def = def. nargs:: Int32
318336 isva = nargs_def > 0 && def. isva
319337 sig = def. sig
320338 if isva
321- vararg = mk_tuplecall! (compact, argexprs[nargs_def: end ], compact . result[idx][ :line ] )
339+ vararg = mk_tuplecall! (compact, argexprs[nargs_def: end ], topline )
322340 argexprs = Any[argexprs[1 : (nargs_def - 1 )]. .. , vararg]
323341 end
324- mi = item. mi
325- is_opaque = isa (mi. def, Method) && mi. def. is_for_opaque_closure
342+ is_opaque = def. is_for_opaque_closure
326343 if is_opaque
327344 # Replace the first argument by a load of the capture environment
328345 argexprs[1 ] = insert_node_here! (compact,
329346 NewInstruction (Expr (:call , GlobalRef (Core, :getfield ), argexprs[1 ], QuoteNode (:captures )),
330- spec. ir. argtypes[1 ], compact . result[idx][ :line ] ))
347+ spec. ir. argtypes[1 ], topline ))
331348 end
332349 flag = compact. result[idx][:flag ]
333350 boundscheck_idx = boundscheck
0 commit comments