Skip to content

Commit e31f0e4

Browse files
vtjnashaviatesk
andauthored
handle new declare_global intrinsic (#138)
* handle new declare_global intrinsic Ensures all tests pass before and after JuliaLang/julia#58279 based on change from `Expr(:globaldecl, GlobalRef(M, S))` to `Core.declare_global(M, S, true)`, while still ignoring `Expr(:global, S)` from `struct` expanding to `strong=false`. * Update src/codeedges.jl --------- Co-authored-by: Shuhei Kadowaki <[email protected]>
1 parent da85f5e commit e31f0e4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/codeedges.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,21 @@ function add_links!(target::Pair{Union{SSAValue,SlotNumber,GlobalRef},Links}, @n
339339
# Avoid putting named callees on the namestore
340340
arng = 2:length(stmt.args)
341341
end
342+
if f isa GlobalRef && f == GlobalRef(Core, :declare_global) && 3 <= length(stmt.args) <= 5
343+
# Core.declare_global(module::Module, name::Symbol, strong::Bool=false, [ty::Type])
344+
m = stmt.args[2]
345+
s = stmt.args[3]
346+
strong = length(stmt.args) >= 4 ? stmt.args[4] === true : false
347+
if strong && m isa Module && s isa QuoteNode && s.value isa Symbol
348+
a = GlobalRef(m, s.value::Symbol)
349+
namestore = get!(Links, cl.namepreds, a) # TODO should this information be tracked in the separate `cl.namedecls` store?
350+
push!(namestore, targetid)
351+
if targetid isa SSAValue
352+
push!(namestore, SSAValue(targetid.id+1)) # +1 for :latestworld
353+
end
354+
end
355+
arng = 4:length(stmt.args)
356+
end
342357
end
343358
for i in arng
344359
add_links!(target, stmt.args[i], cl)

0 commit comments

Comments
 (0)