Skip to content

mir-importer: intrinsic sites that type the call result from the bare destination local fail as a verifier type-mismatch on a projected destination #773

Closed

Description

@nihalpasham

PR #769 taught store_result_to_place to write an intrinsic result through a projected call destination ((*p), x.0, x[i], x[0]) and switched the bitops/saturating/bigint/exact_div sites to type the call result from Place::ty via types::translate_destination_type. Six sites still type it from body.locals()[destination.local].ty, i.e. the bare local:

  • crates/mir-importer/src/translator/terminator/intrinsics/float_math.rs:626 (float-math placeholder calls) and :497 (tuple-result path, destination tuple type)
  • crates/mir-importer/src/translator/terminator/mod.rs:2637 (select_unpredictable)
  • crates/mir-importer/src/translator/terminator/intrinsics/memory.rs:861 and :954 (DynamicSharedArray::get/offset pointee extraction from the destination type)
  • crates/mir-importer/src/translator/terminator/intrinsics/generated.rs:22382 (elect_sync tuple destination; the template that emits it is crates/cuda-intrinsics-gen/src/render.rs:10976)

With a projected destination (custom MIR only, e.g. RET.1 = powf(...)), the call op is created with the whole aggregate's type (or the pointer's type for (*p)), and store_result_to_place then stores that mistyped value through the correctly typed projected address. The pipeline dies as a MirStoreOp verifier type-mismatch ("Compilation error: invalid input program.") instead of either a correct store or the clean "unsupported construct" diagnostic the four fixed sites now guarantee.

Fix: switch each site to types::translate_destination_type(ctx, body, destination, &loc); for generated.rs update the render.rs template and regenerate. The two memory.rs sites match on the destination's RawPtr kind to extract a pointee, so they want the projected Place::ty before that match rather than the local's type. Add custom-MIR coverage alongside the mir_projected_call_destination example or as importer unit tests.

Severity: low (reachable only from #[custom_mir]), but the failure mode is a confusing verifier error rather than a diagnostic.

Activity

  1. added
    bug
    intrinsics
    codegen
    on Aug 10, 2026
  2. added a commit that references this issue on Aug 10, 2026
    3f24194
  3. added a commit that references this issue on Aug 10, 2026
    4574dda
  4. added a commit that references this issue on Aug 10, 2026
    84e663e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcodegenintrinsics

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions