Skip to content

Commit

Permalink
effects: fix #52843, account for mutable values directly embedded to IR
Browse files Browse the repository at this point in the history
Fixes another variant of #52531.
  • Loading branch information
aviatesk committed Jan 12, 2024
1 parent 5c0a2a6 commit fd13cf0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 6 additions & 6 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2267,11 +2267,7 @@ function abstract_eval_value_expr(interp::AbstractInterpreter, e::Expr, vtypes::
end

function abstract_eval_special_value(interp::AbstractInterpreter, @nospecialize(e), vtypes::Union{VarTable,Nothing}, sv::AbsIntState)
if isa(e, QuoteNode)
merge_effects!(interp, sv, Effects(EFFECTS_TOTAL;
inaccessiblememonly = is_mutation_free_argtype(typeof(e.value)) ? ALWAYS_TRUE : ALWAYS_FALSE))
return Const(e.value)
elseif isa(e, SSAValue)
if isa(e, SSAValue)
return abstract_eval_ssavalue(e, sv)
elseif isa(e, SlotNumber)
if vtypes !== nothing
Expand All @@ -2293,7 +2289,11 @@ function abstract_eval_special_value(interp::AbstractInterpreter, @nospecialize(
elseif isa(e, GlobalRef)
return abstract_eval_globalref(interp, e, sv)
end

if isa(e, QuoteNode)
e = e.value
end
merge_effects!(interp, sv, Effects(EFFECTS_TOTAL;
inaccessiblememonly = is_mutation_free_argtype(typeof(e)) ? ALWAYS_TRUE : ALWAYS_FALSE))
return Const(e)
end

Expand Down
6 changes: 6 additions & 0 deletions test/compiler/effects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1052,3 +1052,9 @@ top_52531(_) = (set_initialized52531!(true); nothing)
@test !is_initialized52531()
top_52531(0)
@test is_initialized52531()

const ref52843 = Ref{Int}()
@eval func52843() = ($ref52843[] = 1; nothing)
@test !Core.Compiler.is_foldable(Base.infer_effects(func52843))
let; Base.Experimental.@force_compile; func52843(); end
@test ref52843[] == 1

0 comments on commit fd13cf0

Please sign in to comment.