Skip to content

Commit

Permalink
irinterp: refine :nothrow only when it is not proved yet
Browse files Browse the repository at this point in the history
This makes irinterp not override `:nothrow=true` that are assumed by
`Base.@assume_effects`.
  • Loading branch information
aviatesk committed Aug 2, 2023
1 parent 3eddd17 commit 7878843
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 5 additions & 2 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1153,8 +1153,11 @@ function semi_concrete_eval_call(interp::AbstractInterpreter,
# that are newly resovled by irinterp
# state = InliningState(interp)
# ir = ssa_inlining_pass!(irsv.ir, state, propagate_inbounds(irsv))
new_effects = Effects(result.effects; nothrow)
return ConstCallResults(rt, SemiConcreteResult(mi, ir, new_effects), new_effects, mi)
effects = result.effects
if !is_nothrow(effects)
effects = Effects(effects; nothrow)
end
return ConstCallResults(rt, SemiConcreteResult(mi, ir, effects), effects, mi)
end
end
end
Expand Down
13 changes: 13 additions & 0 deletions test/compiler/effects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -998,3 +998,16 @@ f50198() = (hf50198(Ref(:x)[]); nothing)
f50311(x, s) = Symbol(s)
g50311(x) = Val{f50311((1.0, x), "foo")}()
@test fully_eliminated(g50311, Tuple{Float64})

# irinterp should refine `:nothrow` information only if profitable
Base.@assume_effects :nothrow function irinterp_nothrow_override(x, y)
z = sin(y)
if x
return "julia"
end
return z
end
@test Base.infer_effects((Float64,)) do y
isinf(y) && return zero(y)
irinterp_nothrow_override(true, y)
end |> Core.Compiler.is_nothrow

0 comments on commit 7878843

Please sign in to comment.