Skip to content

Commit

Permalink
Canonicalize IR to disallow mutable GlobalRef in value position (Juli…
Browse files Browse the repository at this point in the history
…aLang#39893)

Generally we assume parameters can be duplicated without seeing
side-effects. That is not entirely true of mutable globals and
multi-threading.

Refs: JuliaLang#36450
Fixes: JuliaLang#39508
  • Loading branch information
vtjnash authored and ElOceanografo committed May 4, 2021
1 parent 454ef42 commit 5695c2d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/compiler/ssair/slot2ssa.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function fixemup!(cond, rename, ir::IRCode, ci::CodeInfo, idx::Int, @nospecializ
return nothing
end
op[] = x
elseif isa(val, GlobalRef) && !isdefined(val.mod, val.name)
elseif isa(val, GlobalRef) && !(isdefined(val.mod, val.name) && isconst(val.mod, val.name))
op[] = NewSSAValue(insert_node!(ir, idx, Any, val).id - length(ir.stmts))
end
end
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/ssair/verify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function check_op(ir::IRCode, domtree::DomTree, @nospecialize(op), use_bb::Int,
end
end
elseif isa(op, GlobalRef)
if !isdefined(op.mod, op.name)
if !isdefined(op.mod, op.name) || !isconst(op.mod, op.name)
@verify_error "Unbound GlobalRef not allowed in value position"
error("")
end
Expand Down

0 comments on commit 5695c2d

Please sign in to comment.