Skip to content

Commit a215b37

Browse files
authored
1.10: inlining: fix joint_effects calculation (#53076)
This particular fix was part of #50805, but it wasn't included in version 1.10, leading to situations where an incorrect `:nothrow` could occur in 1.10 (#53062). This commit implements a minimal correction in 1.10 and also added some test cases. Fixes #53062.
1 parent 2c8ecd3 commit a215b37

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

base/compiler/ssair/inlining.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ function compute_inlining_cases(@nospecialize(info::CallInfo), flag::UInt8, sig:
14081408
fully_covered &= split_fully_covered
14091409
end
14101410

1411-
fully_covered || (joint_effects = Effects(joint_effects; nothrow=false))
1411+
(handled_all_cases & fully_covered) || (joint_effects = Effects(joint_effects; nothrow=false))
14121412

14131413
if handled_all_cases && revisit_idx !== nothing
14141414
# we handled everything except one match with unmatched sparams,

test/compiler/inline.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,3 +2096,20 @@ let src = code_typed1() do
20962096
end
20972097
@test count(isinvoke(:iterate), src.code) == 0
20982098
end
2099+
2100+
# JuliaLang/julia#53062: proper `joint_effects` for call with empty method matches
2101+
let ir = first(only(Base.code_ircode(setproperty!, (Base.RefValue{Int},Symbol,Base.RefValue{Int}))))
2102+
i = findfirst(iscall((ir, convert)), ir.stmts.inst)::Int
2103+
@test iszero(ir.stmts.flag[i] & Core.Compiler.IR_FLAG_NOTHROW)
2104+
end
2105+
function issue53062(cond)
2106+
x = Ref{Int}(0)
2107+
if cond
2108+
x[] = x
2109+
else
2110+
return -1
2111+
end
2112+
end
2113+
@test !Core.Compiler.is_nothrow(Base.infer_effects(issue53062, (Bool,)))
2114+
@test issue53062(false) == -1
2115+
@test_throws MethodError issue53062(true)

0 commit comments

Comments
 (0)