Skip to content

Replace private GEP inbounds metadata with upstream Pliron no-wrap flags #1231

Closed

Description

@uurl

CUDA_OXIDE currently preserves the distinction between ordinary and wrapping pointer offsets using private LLVM-dialect metadata.

This was introduced in #612 to fix wrapping pointer-offset lowering: ordinary pointer offsets may carry the LLVM inbounds contract, while wrapping raw-pointer offsets must not be emitted as getelementptr inbounds.

At the moment, that distinction is represented in two layers:

  • MIR keeps mir_ptr_offset_inbounds, which models the Rust-level semantic distinction.
  • The LLVM dialect carries a private cuda_oxide_gep_inbounds marker consumed by llvm-export.

Pliron now has first-class support for LLVM GEP no-wrap flags through pliron-org/pliron#244:

  • inbounds
  • nusw
  • nuw
  • canonical inbounds => nusw semantics
  • GetElementPtrOp::new_with_no_wrap_flags
  • preservation across LLVM IR conversion

CUDA_OXIDE should adopt that upstream representation and remove the private LLVM-level shim.

Scope

  • Keep the MIR-level mir_ptr_offset_inbounds marker because it represents Rust source semantics.
  • Lower ordinary pointer offsets to GEPs carrying GepNoWrapFlags::INBOUNDS.
  • Lower wrapping pointer offsets to GEPs with no no-wrap flags.
  • Replace existing production GEP sites that previously relied on CUDA_OXIDE's implicit inbounds behavior with explicit upstream flags.
  • Keep dynamic shared-memory byte-offset GEPs unflagged: the [0 x i8] declaration does not establish LLVM's allocated-object inbounds contract for non-zero runtime offsets.
  • Teach llvm-export to emit Pliron's INBOUNDS, NUSW, and NUW flags.
  • Remove cuda_oxide_gep_inbounds and its associated helpers.
  • Add regression coverage for the supported flag combinations and pointer-offset semantics.

Acceptance criteria

  • No remaining uses of the private cuda_oxide_gep_inbounds representation.
  • Ordinary pointer offsets continue to export as getelementptr inbounds.
  • Wrapping pointer offsets export as plain getelementptr.
  • Dynamic shared-memory addressing remains plain GEP.
  • plain, nusw, nuw, inbounds, and inbounds nuw export correctly.
  • Workspace tests and Clippy pass.
  • Full compile-only smoketest suite passes.
  • ptr_offset_from and dynamic_smem pass on real GPU execution.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions