From 86f3a0d7d7479a1354c217ba3ce1540cc6490322 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Wed, 17 Sep 2025 14:34:45 +0000 Subject: [PATCH 1/2] handle new declare_global intrinsic Ensures all tests pass before and after https://github.com/JuliaLang/julia/pull/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`. --- src/codeedges.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/codeedges.jl b/src/codeedges.jl index 29aeb81..190de28 100644 --- a/src/codeedges.jl +++ b/src/codeedges.jl @@ -339,6 +339,21 @@ function add_links!(target::Pair{Union{SSAValue,SlotNumber,GlobalRef},Links}, @n # Avoid putting named callees on the namestore arng = 2:length(stmt.args) end + if f isa GlobalRef && f == GlobalRef(Core, :declare_global) && 3 <= length(stmt.args) <= 5 + # Core.declare_global(module::Module, name::Symbol, strong::Bool=false, [ty::Type]) + m = stmt.args[2] + s = stmt.args[3] + strong = length(stmt.args) >= 4 ? stmt.args[4] === true : false + if strong && m isa Module && s isa QuoteNode && s.value isa Symbol + a = GlobalRef(m, s.value) + namestore = get!(Links, cl.namepreds, a) # TODO should this information be tracked in the separate `cl.namedecls` store? + push!(namestore, targetid) + if targetid isa SSAValue + push!(namestore, SSAValue(targetid.id+1)) # +1 for :latestworld + end + end + arng = 4:length(stmt.args) + end end for i in arng add_links!(target, stmt.args[i], cl) From 460ea66962abbbc43ccd7d96bcbaf68a389595c8 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com> Date: Tue, 30 Sep 2025 03:29:05 +0900 Subject: [PATCH 2/2] Update src/codeedges.jl --- src/codeedges.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codeedges.jl b/src/codeedges.jl index 190de28..00a727b 100644 --- a/src/codeedges.jl +++ b/src/codeedges.jl @@ -345,7 +345,7 @@ function add_links!(target::Pair{Union{SSAValue,SlotNumber,GlobalRef},Links}, @n s = stmt.args[3] strong = length(stmt.args) >= 4 ? stmt.args[4] === true : false if strong && m isa Module && s isa QuoteNode && s.value isa Symbol - a = GlobalRef(m, s.value) + a = GlobalRef(m, s.value::Symbol) namestore = get!(Links, cl.namepreds, a) # TODO should this information be tracked in the separate `cl.namedecls` store? push!(namestore, targetid) if targetid isa SSAValue