Repository navigation
Conversation
ea576f4 to
1f22538
Compare
The docs gate runs `cargo doc` without `--document-private-items`, so it never renders a private item and never checks the intra-doc links in one. #1014 and #1042 cleaned `cuda-macros`, `mir-importer/statement.rs` and the codegen backend's collector; this is one of the four that were left: error: unresolved link to `classify_op` --> crates/llvm-export/src/export/ops.rs:55 `classify_op` is a `macro_rules!` defined further down the same file, at :138. A `macro_rules!` macro is in scope only textually after its definition unless it is exported, so no path resolves from a doc comment above it -- rustdoc says as much: "`macro_rules` named `classify_op` exists in this crate, but it is not in scope at this link's location". It becomes a plain code span, and since the sentence is one step of a four-step contract about this file, it gains "below" so the reference still points somewhere. Three of the four remain. One is `make_disjoint_slice_struct` in `mir-lower/src/convert/ops/aggregate.rs`, which needs only a `crate::convert::types::` prefix; the other two are `MirFieldAddrOp` and `MirArrayElementAddrOp` in `mir-importer/src/translator/rvalue.rs`. Both files are under open pull requests (#1062 and #1064 for the first, #1059 and #1062 for the second), so they are left rather than raced. `--document-private-items` can join the docs gate once they land. Verified: `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --document-private-items -p llvm-export` reports one unresolved link on `main` and none with this change. The gate's own invocation passes before and after. fmt clean. Comment-only change. Signed-off-by: Vyncint Ng <[email protected]>
|
Signed-off-by: Raul Estrada <[email protected]>
…nt Erased tail slices DisjointSlice::get_thread_local is not declared anywhere in cuda-device, so both dispatch arms and the emitter were unreachable. The emitter also built its *mut T result through the kind-erased constructor and stored it into a rustc-typed destination, which the new kind-aware verification would reject if the path ever became reachable. The three DST-tail reconstruction sites keep MirSliceType::get on purpose; comments now state the invariant (projection-internal values stay Erased until an Rvalue::Ref/AddressOf boundary retypes them). Signed-off-by: nihalpasham <[email protected]>
Three example kernels exposed two gaps in the kind-preservation policy this PR documents: 1. Intrinsic results were stored with the normalization-only path, so an emitter-internal Erased pointer result could not take the destination slot's rustc-declared kind and MirStoreOp verification failed (mathdx_ffi_test: *mut i8 in AS3, mcast_barrier_test: *const u64 in AS7). A compiler-recognized device operation is one of the documented Rust-typed boundaries, so emit_store_result_and_goto now stores through store_local_at_rust_boundary, which establishes the declared kind while still requiring the same pointee shape. 2. The Rvalue::Ref boundary now emits a kind-only mir.cast <PtrToPtr> between wgmma_fence and the MMA, which the deferred-accumulator region matchers treated as an unsupported op, so fusion silently declined and lowering failed (wgmma_mma_bf16). Kind-only retypes between thin pointers with the same pointee and address space lower to nothing, so both the linear/pipeline walker and the counted-loop whitelist now look through them. Signed-off-by: nihalpasham <[email protected]>
Verify exact Rust and ABI call boundaries, including closure receivers and drop glue, and make pointer-producing casts, projections, aggregates, intrinsics, and storage operations preserve or explicitly establish their authority. Close aggregate and canonical-function-token laundering paths, preserve raw kinds through NVVM cluster mapping, and run whole-tree producer checks before pointer kinds are erased. Canonicalize harmless pointer-kind reborrows in deferred WGMMA accumulator matching, with counted-loop, verifier-negative, and real Rust pipeline coverage. Signed-off-by: nihalpasham <[email protected]>
9230009 to
f65dacb
Compare
|
Updated #1062 to signed head The enforced boundary is:
Pointer kind remains an auditable source classification, not an optimizer proof. This PR still emits no Validation on the final tree:
Hosted CI needs to run on the new head |
Signed-off-by: nihalpasham <[email protected]>
|
Closing this PR because the pointer-kind model is not sound or complete enough to become a compiler invariant.
I am replacing this with exact source types saved per MIR operation and one shared, fail-closed pointer-construction policy. LLVM alias and validity attributes will come from a separate proof, not from pointer labels alone. #413 stays open for that replacement. |
Part of #413.
This is a fresh implementation following the design feedback from #1040.
Summary
Preserve the Rust source-level pointer/reference category through MIR import and lowering.
This adds
MirPointerKindto distinguish:&T->SharedRef&mut T->UniqueRef*const T->RawConst*mut T->RawMutErasedThe kind is retained by
MirPtrTypeandMirSliceType, propagated through MIR import, and intentionally erased during LLVM lowering.Motivation
The MIR dialect previously preserved pointer mutability and address space, but not whether a pointer originated from a Rust reference or a raw pointer.
That distinction matters if later passes want to reason about Rust aliasing semantics. In particular,
*mut Tand&mut Tare both writable pointers, but only the latter carries Rust uniqueness semantics.This change records that distinction without introducing LLVM alias metadata or changing the physical pointer representation.
Transition policy
Pointer-kind changes are restricted according to the semantic operation that produced the value.
Explicit Rust semantic boundaries
Operations whose result type is authoritative in rustc may establish a new concrete pointer kind:
Rvalue::RefRvalue::AddressOfSharedArray::as_ptr,as_mut_ptr, andas_raw_mut_ptrThis allows legitimate transitions such as:
for a reborrow like:
Generic representation normalization
Generic address-space, storage, projection, and representation normalization may:
but may not perform:
This prevents laundering sequences such as:
Local storage does not establish new Rust pointer semantics.
SharedArray
SharedArraypointer-producing intrinsics now use their rustc-declared result type instead of producing anErasedgeneric pointer and relying on later storage normalization.Therefore:
while CUDA address space remains independent from Rust pointer kind.
Lowering
MirPointerKindis semantic-only and is deliberately erased during MIR-to-LLVM conversion.This PR does not infer or emit:
noaliasreadonlydereferenceableAny future use of Rust aliasing facts should be introduced separately with an audited policy.
Retagalso remains a codegen no-op; this change does not attempt to model dynamic Stacked Borrows or Tree Borrows state.Validation
Validated with:
All checks pass.
The end-to-end
vecaddbuild covers the reborrow case that exposed the overly restrictive transition policy in the previous implementation, whileaddressof_sharedarrayvalidates pointer-kind propagation through theSharedArraycompiler-recognized pointer APIs.Scope
This PR covers the pointer/reference-kind representation, import, propagation, and lowering portion of #413.
The broader tracking issue should remain open for future provenance and aliasing policy work.