Skip to content

Commit 5206bca

Browse files
committed
Ignore line number node when counting expressions for inlining. Fix #13551
1 parent aa68ea7 commit 5206bca

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

base/inference.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,7 @@ end
19341934
function occurs_more(e::ANY, pred, n)
19351935
if isa(e,Expr)
19361936
e = e::Expr
1937+
e.head === :line && return 0
19371938
c = 0
19381939
for a = e.args
19391940
c += occurs_more(a, pred, n)
@@ -2620,10 +2621,17 @@ function inline_worthy(body::Expr, cost::Integer=1000) # precondition: 0 < cost;
26202621
return false
26212622
end
26222623
symlim = 1000 + 5_000_000 ÷ cost
2623-
if length(body.args) < (symlim + 500) ÷ 1000
2624+
nargs = 0
2625+
for arg in body.args
2626+
if (!isa(arg, LineNumberNode) &&
2627+
!(isa(arg, Expr) && (arg::Expr).head === :line))
2628+
nargs += 1
2629+
end
2630+
end
2631+
if nargs < (symlim + 500) ÷ 1000
26242632
symlim *= 16
26252633
symlim ÷= 1000
2626-
if occurs_more(body, e->true, symlim) < symlim
2634+
if occurs_more(body, e->(!isa(e, LineNumberNode)), symlim) < symlim
26272635
return true
26282636
end
26292637
end
@@ -2661,7 +2669,7 @@ end
26612669
const corenumtype = Union{Int32,Int64,Float32,Float64}
26622670

26632671
function inlining_pass(e::Expr, sv, ast)
2664-
if e.head == :method
2672+
if e.head === :method
26652673
# avoid running the inlining pass on function definitions
26662674
return (e,())
26672675
end

0 commit comments

Comments
 (0)