Skip to content

LLVM ERROR: "Vector elements must have same size" with -Zmir-opt-level=3 #104037

@matthiaskrgr

Description

@matthiaskrgr

Code

You may need a debug-assertions build of llvm to reproduce this.
Interestingly this only triggers with mir-opt-level 3 but not with 2.

#[derive(Clone)]
pub struct Foo(Bar, u32);

#[derive(Clone, Copy)]
pub struct Bar(u8, u8, u8);

fn main() {
    let foo: Vec<Foo> = Vec::new();
    let _ = foo.clone();
}

Meta

rustc --version --verbose:

rustc @ 371100b1fb811e604f7451eff3b06960587fe1af with full rustc + llvm debug assertions

Error output

rustc -Copt-level=3 103380.rs

rustc: /home/matthias/vcs/github/rust_debug_assertions/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2907: llvm::Value *llvm::InnerLoopVectorizer::createBitOrPointerCast(llvm::Value *, llvm::VectorType *, const llvm::DataLayout &): Assertion `(DL.getTypeSizeInBits(SrcElemTy) == DL.getTypeSizeInBits(DstElemTy)) && "Vector elements must have same size"' failed.
Backtrace

rustc: /home/matthias/vcs/github/rust_debug_assertions/src/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2907: llvm::Value *llvm::InnerLoopVectorizer::createBitOrPointerCast(llvm::Value *, llvm::VectorType *, const llvm::DataLayout &): Assertion `(DL.getTypeSizeInBits(SrcElemTy) == DL.getTypeSizeInBits(DstElemTy)) && "Vector elements must have same size"' failed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-mir-optArea: MIR optimizationsC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way

    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