← Back to Pull requests

FinalLowerGC: emit GC frame slot addresses as byte offsets #65275

Closed
unknown closed this pull request without merging on Nov 26, 2026 04:15 UTC
View on GitHub
unknown unknown commented on Nov 25, 2026 21:53 UTC
Author

julia.get_gc_frame_slot is lowered to getelementptr inbounds ptr, ptr %gcframe, i32 N, which the InstCombine run after GC lowering rewrites to its canonical form, getelementptr inbounds nuw i8, ptr %gcframe, i64 8N. Each rewrite puts the frame alloca back on the worklist, and visiting the alloca walks all of its uses (llvm/llvm-project#242235), so that InstCombine run is quadratic in the number of GC-frame stores.

A function that keeps many split-union values with inline roots live across many safepoints gets tens of thousands of such stores. Broadcasting getproperty over the 18 property names of an OrdinaryDiffEq ODESolution (what ConstructionBase.getproperties does) gets 19,000 of them, and that one InstCombine run took 2.3 s of the 5.5 s it took to compile. This emits the canonical form directly, so InstCombine has nothing to rewrite: the compile drops to 3.4 s, and the optimized IR and machine code are unchanged.

Package-free reproducer (run with NF=40 JULIA_OBJCACHE=0; about 1.9 s before and 1.6 s after):

const N = parse(Int, get(ENV, "NF", "18"))
ftype(i) = i % 6 == 1 ? :Int : i % 6 == 2 ? :Bool : i % 6 == 3 ? :Float64 : :(Vector{Float64})
@eval struct Big
    $([:($(Symbol(:f, i))::$(ftype(i))) for i in 1:N]...)
end
struct Wrap; b::Big; end
Base.getproperty(b::Big, s::Symbol) = s === :w ? Wrap(b) : getfield(b, s)
g(b, names) = getproperty.((b,), names)
@time precompile(g, (Big, NTuple{N,Symbol}))

The rest of the time in such a function (instruction selection, scheduling, DSE) comes from the number of stores itself: late GC lowering stores every live root again in each safepoint block that entry can reach without passing a safepoint. That is a separate question and not addressed here.

Written with Claude Code.

Diff: 226 lines (+169 / -57) across 2 files Reviewer: vtjnash Review duration: 381m
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 226 lines diff across 2 files
0.37
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.325
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #65275"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 36.9% (MEDIUM) · Higher = larger blast radius
36.9%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.6% · Safe to merge
14.6%