← Back to Pull requests

Run SimplifyCFG before the bare AlwaysInlinerPass runs #4050

Closed
unknown closed this pull request without merging on Nov 20, 2026 12:38 UTC
View on GitHub
unknown unknown commented on Nov 14, 2026 00:12 UTC
Author

The three places in compiler.jl that ran remove_alwaysinline_roots!(mod); run!(AlwaysInlinerPass(), mod) directly (lower_convention, the BLAS bitcode replacement, and the post-AD wrapper inlining) now call inline_alwaysinline!(mod). This runs one pass pipeline: SimplifyCFG on every function, then RemoveAlwaysInlineRootsPass, then AlwaysInlinerPass. The two pipelines in optimize.jl already have this shape.

LLVM 18's AlwaysInlinerPass computes BlockFrequencyInfo for each callee, and BranchProbabilityInfo is superlinear in the number of blocks inside a loop. Unoptimized KernelAbstractions kernel bodies can be very large: in an Oceananigans hydrostatic model with GM/Redi (IsopycnalSkewSymmetricDiffusivity), the tracer tendency kernel compute_hydrostatic_free_surface_Gc! has ~285k blocks, and the inliner spent ~340 s on each of the T and S kernels in lower_convention. After SimplifyCFG the same function has 13 blocks and inlining takes well under a second.

Measured on a 4° global ocean (90×40×20, implicit-free-surface variant of MITgcm's tutorial_tracer_adjsens), first reverse-mode autodiff of 2 time steps including compilation, Julia 1.12.7, same environment except for this PR:

| | reverse pass (incl. compile) |
|---|---|
| main (01265672) | 1353 s |
| first version of this PR | 1006 s |

These numbers are from the first version of this PR, which ran SimplifyCFG only on alwaysinline functions with more than 1000 blocks, one function at a time. The current version runs it on all functions at those three sites. It has not been re-timed. The gradients were bit-identical between the two runs and agree with central finite differences to 1e-10 to 1e-7.

Tests: after rebasing onto main 9cc1c3a1, basic, callconv, blas, passes, optimize and rooted_args pass on Julia 1.12 and 1.13.

🤖 Generated with Claude Code

Diff: 238 lines (+178 / -60) across 2 files Reviewer: vchuravy Review duration: 9386m
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.37) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 238 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%
56%
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.328
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4050"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% 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: 37.2% (MEDIUM) · Higher = larger blast radius
37.2%
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: 56.8% · Lower = rushed or shallow review
56.8%
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: 16.1% · Safe to merge
16.1%