Drop constant-memory alias claims from functions Enzyme inlines #4046
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.39) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 264 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.334
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4046"
general
weight: 0.35
vchuravy
Julia tags a load from an immutable object reached through an argument as a read of constant memory (
jtbaa_constTBAA and thejnoalias_constalias scope), which no store in the same function may alias. That holds for a Julia function on its own. It stops holding once LLVM inlines the function into a caller that constructs the object: the caller's initializing stores (taggedjnoalias_data) and the callee's loads then share a function, and LLVM is entitled to fold the loads toundef.Enzyme always-inlines rule functions, so this can miscompile a custom rule that reads a boxed immutable argument built in the differentiated function. This PR removes the claim (
!tbaa,!alias.scope,!noalias) from such loads in anyalwaysinlinefunction, inremove_alwaysinline_roots!, which already runs before eachAlwaysInlinerPass. Loads without the constant-memory claim, and functions that are not inlined, are left alone.How it was found
#4026 lets a boxed immutable with mixed activity reach a reverse rule. On Julia 1.13 this returns
NaN:The optimized IR has the rule's
tape.valueload folded to a constant. Julia 1.12 emits the same metadata; the optimizer does not happen to exploit it there. With this change the reproducer returns((6.0,), 9.0)on 1.13.Testing
test/passes.jl: passes on 1.10, 1.12 and 1.13.maina boxed immutable rule argument hits the assertion that #4026 fixes first, so the reproducer above only runs on top of #4026. With both applied,rules/rules.jl, the mixed-activity tests, the keyword-rule tests andrules/rule_inlining.jlpass locally on 1.10 through 1.13.