Skip to content

Commit 01c3a2e

Browse files
JeffBezansonKristofferC
authored andcommitted
handle GlobalRef in getfield elim pass (#34322)
1 parent e7b0d52 commit 01c3a2e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

base/compiler/ssair/passes.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,13 @@ function lift_leaves(compact::IncrementalCompact, @nospecialize(stmt),
370370
end
371371
elseif isa(leaf, QuoteNode)
372372
leaf = leaf.value
373+
elseif isa(leaf, GlobalRef)
374+
mod, name = leaf.mod, leaf.name
375+
if isdefined(mod, name) && isconst(mod, name)
376+
leaf = getfield(mod, name)
377+
else
378+
return nothing
379+
end
373380
elseif isa(leaf, Union{Argument, Expr})
374381
return nothing
375382
end

test/compiler/irpasses.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,8 @@ end
290290
let K = rand(2,2)
291291
@test test_29253(K) == 2
292292
end
293+
294+
# check getfield elim handling of GlobalRef
295+
const _some_coeffs = (1,[2],3,4)
296+
splat_from_globalref(x) = (x, _some_coeffs...,)
297+
@test splat_from_globalref(0) == (0, 1, [2], 3, 4)

0 commit comments

Comments
 (0)