Skip to content

Commit

Permalink
1.10: inlining: fix joint_effects calculation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aviatesk committed Jan 27, 2024
1 parent ece8b7b commit e869083
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ function compute_inlining_cases(@nospecialize(info::CallInfo), flag::UInt8, sig:
fully_covered &= split_fully_covered
end

fully_covered || (joint_effects = Effects(joint_effects; nothrow=false))
(handled_all_cases & fully_covered) || (joint_effects = Effects(joint_effects; nothrow=false))

if handled_all_cases && revisit_idx !== nothing
# we handled everything except one match with unmatched sparams,
Expand Down
17 changes: 17 additions & 0 deletions test/compiler/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2096,3 +2096,20 @@ let src = code_typed1() do
end
@test count(isinvoke(:iterate), src.code) == 0
end

# JuliaLang/julia#53062: proper `joint_effects` for call with empty method matches
let ir = first(only(Base.code_ircode(setproperty!, (Base.RefValue{Int},Symbol,Base.RefValue{Int}))))
i = findfirst(iscall((ir, convert)), ir.stmts.inst)::Int
@test iszero(ir.stmts.flag[i] & Core.Compiler.IR_FLAG_NOTHROW)
end
function issue53062(cond)
x = Ref{Int}(0)
if cond
x[] = x
else
return -1
end
end
@test !Core.Compiler.is_nothrow(Base.infer_effects(issue53062, (Bool,)))
@test issue53062(false) == -1
@test_throws MethodError issue53062(true)

0 comments on commit e869083

Please sign in to comment.