@@ -304,29 +304,47 @@ function ir_inline_item!(compact::IncrementalCompact, idx::Int, argexprs::Vector
304
304
boundscheck:: Symbol , todo_bbs:: Vector{Tuple{Int, Int}} )
305
305
# Ok, do the inlining here
306
306
spec = item. spec:: ResolvedInliningSpec
307
+ sparam_vals = item. mi. sparam_vals
308
+ def = item. mi. def:: Method
307
309
inline_cfg = spec. ir. cfg
308
310
stmt = compact. result[idx][:inst ]
309
311
linetable_offset:: Int32 = length (linetable)
310
312
# Append the linetable of the inlined function to our line table
311
313
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))
315
334
end
316
- (; def, sparam_vals) = item. mi
317
335
nargs_def = def. nargs:: Int32
318
336
isva = nargs_def > 0 && def. isva
319
337
sig = def. sig
320
338
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 )
322
340
argexprs = Any[argexprs[1 : (nargs_def - 1 )]. .. , vararg]
323
341
end
324
- is_opaque = isa (def, Method) && def. is_for_opaque_closure
342
+ is_opaque = def. is_for_opaque_closure
325
343
if is_opaque
326
344
# Replace the first argument by a load of the capture environment
327
345
argexprs[1 ] = insert_node_here! (compact,
328
346
NewInstruction (Expr (:call , GlobalRef (Core, :getfield ), argexprs[1 ], QuoteNode (:captures )),
329
- spec. ir. argtypes[1 ], compact . result[idx][ :line ] ))
347
+ spec. ir. argtypes[1 ], topline ))
330
348
end
331
349
flag = compact. result[idx][:flag ]
332
350
boundscheck_idx = boundscheck
0 commit comments