Skip to content

fix(mir-importer): preserve non-terminating drops - #1361

Open
YunusMutlu wants to merge 1 commit into
NVIDIA:mainfrom
YunusMutlu:fix/drop-noop-termination
Open

YunusMutlu wants to merge 1 commit into
NVIDIA:mainfrom
YunusMutlu:fix/drop-noop-termination

Conversation

@YunusMutlu

Copy link
Copy Markdown
Contributor

Fixes #1360

Summary

Make the device-side drop no-op proof account for non-returning control flow. Previously, effect-free CFG and recursive call cycles could pass the proof, erasing non-terminating destructors and allowing unreachable continuations to execute. The proof now conservatively rejects these cycles while retaining constant-branch pruning, empty-shim handling, and ordinary acyclic CFG reconvergence.

Changes

  • Reject an instance already on the active no-op proof call stack.
  • Track unseen, in-progress, and proven basic blocks to distinguish CFG cycles from ordinary reconvergence.
  • Add two compile-only probes to the existing drop_glue example: a looping destructor and a destructor calling an unconditionally recursive helper.
  • Add an optimized PTX shape check requiring the pre-drop store to lead directly into an unconditional self-loop and rejecting the post-drop store.
  • Document the compile-only boundary and verification commands in the example README.

The existing smoketest runner automatically discovers the shape-check script. No new example, dependency, or integration-test framework is introduced.

Testing

  • just check passes: formatting, clippy, tests, guards, intrinsic checks, and docs.
  • scripts/smoketest.sh -o '^drop_glue$' passes.
  • New example: not applicable; the existing drop_glue example is extended.

Additional validation:

  • Focused importer tests: 1163 passed, 0 failed.
  • The changed example's standalone clippy check passes with -D warnings.
  • Compile-only smoketest passes, including PTX assembly for sm_80 and the optimized shape check.
  • Existing drop_glue GPU runtime checks pass both normally and with CUDA_OXIDE_NO_OPT=1.
  • Existing array_for_loop GPU runtime regression passes.

Commands run:

cargo oxide fmt
git diff --check
git diff --cached --check
cargo test -p mir-importer --lib -- --quiet
cargo clippy --manifest-path crates/rustc-codegen-cuda/examples/drop_glue/Cargo.toml --all-targets -- -D warnings
just check
scripts/smoketest.sh -o '^drop_glue$'
scripts/smoketest.sh --compile-only --verbose -o '^drop_glue$'
CUDA_OXIDE_NO_OPT=1 cargo oxide run drop_glue --arch sm_86
scripts/smoketest.sh --keep-logs -o '^array_for_loop$'
bash crates/rustc-codegen-cuda/examples/drop_glue/verify-code-shape.sh

Compiler/example checks used an explicit CUDA_OXIDE_BACKEND pointing to a snapshot byte-identical to the backend built from the patched working tree.

The shape verifier was also checked against temporary PTX fixtures. It rejects:

  • the baseline miscompile;
  • a pre-drop store followed by ret;
  • a returning continuation with an unrelated self-loop elsewhere in the entry.

It accepts the patched output for both probes.

The divergent kernels were never launched. Their regression coverage is compile-only; GPU runtime results refer to the existing terminating kernels.

The complete just check finished successfully with non-failing warnings from test fixtures and dependency checks. This PR does not change dependencies or lock files.

Checklist

  • All commits signed off (git commit -s).
  • SPDX headers on new source files; existing headers preserved.

@nihalpasham nihalpasham added the cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book label Oct 11, 2026
Signed-off-by: Yunus Mutlu <mutluyunus708@gmail.com>
@YunusMutlu
YunusMutlu force-pushed the fix/drop-noop-termination branch from ccc6877 to 80c4568 Compare October 13, 2026 12:05
@copy-pr-bot

copy-pr-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop no-op analysis incorrectly erases non-terminating destructors

3 participants