Skip to content

Matching on enums with optimizations enabled causes rustc-LLVM errors on the nvptx64-nvidia-cuda target #146742

@FractalFir

Description

@FractalFir

This code:

#![no_std]
pub enum Bug {
    A,
    B,
    C,
}
pub fn debug(t: &Bug) {
    core::hint::black_box(match t {
        Bug::A => "A",
        Bug::B => "B",
        Bug::C => "C",
    });
}

Compiles just fine for the nvptx64 target... if optimizations are disabled.

--target=nvptx64-nvidia-cuda -Copt-level=0

However, as soon as optimizations are turned on, this code raises rustc-LLVM errors.

--target=nvptx64-nvidia-cuda -Copt-level=1
rustc-LLVM ERROR: Circular dependency found in global variable set
Compiler returned: 101

Meta

This bug can be triggered on the newest nightly, and stable versions back to 1.87.

My reproducer does not trigger the issue in 1.86, but I will have to check if the larger codebase I extracted this from works there.

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustcO-NVPTXTarget: the NVPTX LLVM backend for running rust on GPUs, https://llvm.org/docs/NVPTXUsage.htmlT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixes

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions