Skip to content

Commit efad4e3

Browse files
authored
Restore moving GlobalRef out of argument position (JuliaLang#40101)
This was dropped in JuliaLang#40066. I thought this was there because of the side-effect that we used to allow in GlobalRefs, but we also need to avoid inlining it into a PhiNode, and there are data race concerns as well, so put back the outlining. Fixes verifier complaints in `make debug` mode.
1 parent 1006d5f commit efad4e3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

base/compiler/ssair/inlining.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,12 +555,16 @@ function batch_inline!(todo::Vector{Pair{Int, Any}}, ir::IRCode, linetable::Vect
555555
compact.active_result_bb -= 1
556556
refinish = true
557557
end
558-
# At the moment we will allow globalrefs in argument position, turn those into ssa values
558+
# It is possible for GlobalRefs and Exprs to be in argument position
559+
# at this point in the IR, though in that case they are required
560+
# to be effect-free. However, we must still move them out of argument
561+
# position, since `Argument` is allowed in PhiNodes, but `GlobalRef`
562+
# and `Expr` are not, so a substitution could anger the verifier.
559563
for aidx in 1:length(argexprs)
560564
aexpr = argexprs[aidx]
561-
if isa(aexpr, Expr)
562-
argexprs[aidx] = insert_node_here!(compact,
563-
NewInstruction(aexpr, compact_exprtype(compact, aexpr), compact.result[idx][:line]))
565+
if isa(aexpr, Expr) || isa(aexpr, GlobalRef)
566+
ninst = effect_free(NewInstruction(aexpr, compact_exprtype(compact, aexpr), compact.result[idx][:line]))
567+
argexprs[aidx] = insert_node_here!(compact, ninst)
564568
end
565569
end
566570
if isa(item, InliningTodo)

0 commit comments

Comments
 (0)