← Back to Pull requests

Keep pointer arguments of a mismatched call type in their address space #3902

Open
unknown opened this pull request with 194 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 17, 2026 19:49 UTC
Author

<!-- claude-projects-attribution: {"github_login":"vchuravy"} -->
_Requested by Valentin · project thread_

When a call's function type differs from its callee's, recursivelyHandleSubfunction bitcasts 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 passes ptr addrspace(10) objects to the wrapper's ptr parameters. The bitcast between address spaces trips castIsValid(...) && "Invalid cast!" in Enzyme.jl's test/ext/functionwrappers.jl on 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:

  • New lit test ReverseMode/callfntype-addrspace.ll covers both the augmented call and the gradient call. It passes on LLVM 16 and fails without the change.

  • With libEnzyme-23 built from this branch, Enzyme.jl's ext/functionwrappers passes 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

    Diff: 194 lines (+145 / -49) across 2 files Reviewer: wsmoses Review duration: 19016m
    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
    0.41
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 41% (MEDIUM) · Higher = larger blast radius
    41%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 21.9% · Safe to merge
    21.9%