Skip to content

[rustc] ICE: scalable vectors are unsupported in x86_64 calling convention classifier when compiling AArch64 SVE intrinsic returning scalable vector type #153593

@YuanchengJiang

Description

@YuanchengJiang

Description

rustc panics with "scalable vectors are unsupported" when compiling a function that calls an AArch64 SVE LLVM intrinsic returning a scalable vector type (svbool4_t). The crash occurs in the x86_64 calling convention classifier (callconv/x86_64.rs:62) during ABI computation at monomorphization time, even though the type is an AArch64-specific scalable vector that should never reach the x86_64 ABI classifier.

Reproducer

#![crate_type = "lib"]
#![allow(internal_features)]
#![feature(rustc_attrs, link_llvm_intrinsics)]

#[rustc_scalable_vector(4)]
#[allow(non_camel_case_types)]
#[repr(transparent)]
pub struct svbool4_t(bool);

pub fn trigger() -> svbool4_t {
    unsafe extern "C" {
        #[link_name = "llvm.aarch64.sve.whilelo.nxv4i1.u64"]
        fn _svwhilelt_b32_u64(op1: u64, op2: u64) -> svbool4_t;
    }
    unsafe { _svwhilelt_b32_u64(0, 1) }
}

Command

rustc --edition=2021 -C opt-level=1 -C codegen-units=1 reproduce.rs

Expected behavior

Either a graceful error is emitted indicating that AArch64 SVE scalable vector types cannot be used in this context on x86_64, or the ABI classifier correctly skips or handles scalable vector types without panicking.

Actual behavior

thread 'rustc' panicked at compiler/rustc_target/src/callconv/x86_64.rs:62:51:
scalable vectors are unsupported
error: the compiler unexpectedly panicked. This is a bug

Root cause

The call chain is:

fn_abi_of_instance [computing call ABI of `svwhilelt_b32_u64::_svwhilelt_b32_u64`]
  → fn_abi_adjust_for_abi
    → compute_abi_info (x86_64.rs:256)
      → classify_arg (x86_64.rs:106)
        → classify (x86_64.rs:62)  ← panic: scalable vectors are unsupported

The x86_64 classify function encounters a scalable vector type and hits an unconditional panic! with no prior guard. The #[rustc_scalable_vector] attribute marks svbool4_t as a scalable vector, and when _svwhilelt_b32_u64 is monomorphized, its ABI is computed through the x86_64 classifier which does not handle this case gracefully.

Environment

  • Compiler: rustc 1.95.0-nightly
  • Host target: x86_64-unknown-linux-gnu
  • Flags: -C opt-level=1 -C codegen-units=1
  • Requires: #![feature(rustc_attrs, link_llvm_intrinsics)]
  • rustc commit: 9b1f8ff42d110b0ca138116745be921df5dc97e7

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ABIArea: Concerning the application binary interface (ABI)A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.F-scalable-vectors`#[rustc_scalable_vector]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️O-x86_64Target: x86-64 processors (like x86_64-*) (also known as amd64 and x64)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-internal-featuresThis issue requires the use of internal features.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions