Keep pointer arguments of a mismatched call type in their address space #3902
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.41) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.41 · 194 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.315
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #3902"
general
weight: 0.35
wsmoses
<!-- claude-projects-attribution: {"github_login":"vchuravy"} -->
_Requested by Valentin · project thread_
When a call's function type differs from its callee's,
recursivelyHandleSubfunctionbitcasts each mismatched argument of the augmented and gradient calls to the callee's parameter type.Julia 1.14 now emits a direct call to the in-module
jlcapi_cfunction wrapper, for example for a FunctionWrappers.jl call. That call passesptr addrspace(10)objects to the wrapper'sptrparameters. The bitcast between address spaces tripscastIsValid(...) && "Invalid cast!"in Enzyme.jl'stest/ext/functionwrappers.jlon the 1.14+assert CI job.This PR passes such pointers unchanged and makes the call with a function type that matches them, the same way the original call does. An addrspacecast to the parameter type would also be valid IR. But Enzyme.jl treats a cast of a tracked pointer to addrspace 0 as a decay, and it then fails with "did not have sret when expected".
Tests:
ReverseMode/callfntype-addrspace.llcovers both the augmented call and the gradient call. It passes on LLVM 16 and fails without the change.ext/functionwrapperspasses on Julia 1.14.0-beta1+assert and gives the correct gradient.Related: Enzyme.jl 1.14 stack EnzymeAD/Enzyme.jl#4075–#4081.
🤖 Generated with Claude Code