Skip to content

Commit

Permalink
handle GlobalRef in getfield elim pass (#34322)
Browse files Browse the repository at this point in the history
(cherry picked from commit 22817ea)
  • Loading branch information
JeffBezanson authored and KristofferC committed Jan 9, 2020
1 parent 3597a11 commit c1c544e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions base/compiler/ssair/passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ function lift_leaves(compact::IncrementalCompact, @nospecialize(stmt),
end
elseif isa(leaf, QuoteNode)
leaf = leaf.value
elseif isa(leaf, GlobalRef)
mod, name = leaf.mod, leaf.name
if isdefined(mod, name) && isconst(mod, name)
leaf = getfield(mod, name)
else
return nothing
end
elseif isa(leaf, Union{Argument, Expr})
return nothing
end
Expand Down
5 changes: 5 additions & 0 deletions test/compiler/irpasses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,8 @@ end
let K = rand(2,2)
@test test_29253(K) == 2
end

# check getfield elim handling of GlobalRef
const _some_coeffs = (1,[2],3,4)
splat_from_globalref(x) = (x, _some_coeffs...,)
@test splat_from_globalref(0) == (0, 1, [2], 3, 4)

0 comments on commit c1c544e

Please sign in to comment.