Skip to content

Commit 6068525

Browse files
committed
optimizer: address TODO for computing joint_effects more efficiently
1 parent 48c71da commit 6068525

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

base/compiler/ssair/inlining.jl

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,27 +1338,6 @@ function info_effects(@nospecialize(result), match::MethodMatch, state::Inlining
13381338
end
13391339
end
13401340

1341-
function compute_joint_effects(info::Union{ConstCallInfo, Vector{MethodMatchInfo}}, state::InliningState)
1342-
if isa(info, ConstCallInfo)
1343-
(; call, results) = info
1344-
infos = isa(call, MethodMatchInfo) ? MethodMatchInfo[call] : call.matches
1345-
else
1346-
results = nothing
1347-
infos = info
1348-
end
1349-
local all_result_count = 0
1350-
local joint_effects::Effects = EFFECTS_TOTAL
1351-
for i in 1:length(infos)
1352-
meth = infos[i].results
1353-
for (j, match) in enumerate(meth)
1354-
all_result_count += 1
1355-
result = results === nothing ? nothing : results[all_result_count]
1356-
joint_effects = merge_effects(joint_effects, info_effects(result, match, state))
1357-
end
1358-
end
1359-
return joint_effects
1360-
end
1361-
13621341
function compute_inlining_cases(info::Union{ConstCallInfo, Vector{MethodMatchInfo}},
13631342
flag::UInt8, sig::Signature, state::InliningState)
13641343
argtypes = sig.argtypes
@@ -1376,6 +1355,8 @@ function compute_inlining_cases(info::Union{ConstCallInfo, Vector{MethodMatchInf
13761355
local only_method = nothing
13771356
local meth::MethodLookupResult
13781357
local all_result_count = 0
1358+
local joint_effects::Effects = EFFECTS_TOTAL
1359+
local nothrow::Bool = true
13791360
for i in 1:length(infos)
13801361
meth = infos[i].results
13811362
if meth.ambig
@@ -1400,6 +1381,8 @@ function compute_inlining_cases(info::Union{ConstCallInfo, Vector{MethodMatchInf
14001381
for (j, match) in enumerate(meth)
14011382
all_result_count += 1
14021383
result = results === nothing ? nothing : results[all_result_count]
1384+
joint_effects = merge_effects(joint_effects, info_effects(result, match, state))
1385+
nothrow &= match.fully_covers
14031386
any_fully_covered |= match.fully_covers
14041387
if !validate_sparams(match.sparams)
14051388
if !match.fully_covers
@@ -1418,6 +1401,8 @@ function compute_inlining_cases(info::Union{ConstCallInfo, Vector{MethodMatchInf
14181401
end
14191402
end
14201403

1404+
joint_effects = Effects(joint_effects; nothrow)
1405+
14211406
if handled_all_cases && revisit_idx !== nothing
14221407
# we handled everything except one match with unmatched sparams,
14231408
# so try to handle it by bypassing validate_sparams
@@ -1447,9 +1432,6 @@ function compute_inlining_cases(info::Union{ConstCallInfo, Vector{MethodMatchInf
14471432
filter!(case::InliningCase->isdispatchtuple(case.sig), cases)
14481433
end
14491434

1450-
# TODO fuse `compute_joint_effects` into the loop above, which currently causes compilation error
1451-
joint_effects = Effects(compute_joint_effects(info, state); nothrow=handled_all_cases)
1452-
14531435
return cases, (handled_all_cases & any_fully_covered), joint_effects
14541436
end
14551437

0 commit comments

Comments
 (0)