Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reland "Inlining: Remove outdated code path for GlobalRef movement (#46880)" #56382

Merged
merged 2 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -663,18 +663,6 @@ function batch_inline!(ir::IRCode, todo::Vector{Pair{Int,Any}}, propagate_inboun
compact.active_result_bb -= 1
refinish = true
end
# It is possible for GlobalRefs and Exprs to be in argument position
# at this point in the IR, though in that case they are required
# to be effect-free. However, we must still move them out of argument
# position, since `Argument` is allowed in PhiNodes, but `GlobalRef`
# and `Expr` are not, so a substitution could anger the verifier.
for aidx in 1:length(argexprs)
aexpr = argexprs[aidx]
if isa(aexpr, Expr) || isa(aexpr, GlobalRef)
ninst = removable_if_unused(NewInstruction(aexpr, argextype(aexpr, compact), compact.result[idx][:line]))
argexprs[aidx] = insert_node_here!(compact, ninst)
end
end
if isa(item, InliningTodo)
compact.ssa_rename[old_idx] = ir_inline_item!(compact, idx, argexprs, item, boundscheck, state.todo_bbs)
elseif isa(item, UnionSplit)
Expand Down
4 changes: 2 additions & 2 deletions test/compiler/EscapeAnalysis/EscapeAnalysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,8 @@ end
@test has_all_escape(result.state[Argument(3)]) # b
end
let result = @eval EATModule() begin
const Rx = SafeRef{String}("Rx")
$code_escapes((String,)) do s
const Rx = SafeRef(Ref(""))
$code_escapes((Base.RefValue{String},)) do s
Rx[] = s
Core.sizeof(Rx[])
end
Expand Down
7 changes: 7 additions & 0 deletions test/compiler/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2282,3 +2282,10 @@ let;Base.Experimental.@force_compile
f_EA_finalizer(42000)
@test foreign_buffer_checker.finalized
end

# Test that inlining doesn't unnecessarily move things to statement position
@noinline f_noinline_invoke(x::Union{Symbol,Nothing}=nothing) = Core.donotdelete(x)
g_noinline_invoke(x) = f_noinline_invoke(x)
let src = code_typed1(g_noinline_invoke, (Union{Symbol,Nothing},))
@test !any(@nospecialize(x)->isa(x,GlobalRef), src.code)
end