Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM error when cloning Vec of certain struct in release mode #103380

Closed
mat-1 opened this issue Oct 22, 2022 · 4 comments · Fixed by #105415
Closed

LLVM error when cloning Vec of certain struct in release mode #103380

mat-1 opened this issue Oct 22, 2022 · 4 comments · Fixed by #105415
Assignees
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@mat-1
Copy link
Contributor

mat-1 commented Oct 22, 2022

I found this issue when I was compiling one of my large projects, and was able to track it down to the code below. Unfortunately, I haven't been able to reproduce the issue on any other machines other than this one (which is running Ubuntu 20.02.4 on Oracle Cloud, if that matters). The error only seems to happen in release mode in nightly.

Code

#[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 1.66.0-nightly (dcb376115 2022-10-20)
binary: rustc
commit-hash: dcb376115066d111dbf5f13d5ac2a2dbe8c12add
commit-date: 2022-10-20
host: aarch64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2

Error output

Invalid bitcast
  %63 = bitcast <4 x i32> %62 to <4 x i24>
Invalid bitcast
  %65 = bitcast <4 x i32> %64 to <4 x i24>
in function _ZN67_$LT$alloc..vec..Vec$LT$T$C$A$GT$$u20$as$u20$core..clone..Clone$GT$5clone17h90016bd0a1a635e4E
LLVM ERROR: Broken function found, compilation aborted!

@mat-1 mat-1 added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 22, 2022
@Rageking8
Copy link
Contributor

@rustbot label +A-LLVM

@rustbot rustbot added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Oct 22, 2022
@nikic
Copy link
Contributor

nikic commented Nov 1, 2022

I can reproduce this via rustc +nightly --target=aarch64-unknown-linux-gnu -C opt-level=3 test.rs.

@nikic
Copy link
Contributor

nikic commented Nov 1, 2022

Reduced:

target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"

define void @test(ptr %start, ptr %end) {
entry:
  br label %loop

loop:
  %ptr = phi ptr [ %start, %entry ], [ %ptr.next, %loop.latch ]
  %cmp = icmp eq ptr %ptr, %end
  br i1 %cmp, label %exit, label %loop.latch

loop.latch:
  %ptr.next = getelementptr inbounds i64, ptr %ptr, i64 1
  %v1 = load i32, ptr %ptr, align 4
  %gep = getelementptr inbounds i8, ptr %ptr, i64 4
  %v2 = load i24, ptr %gep, align 4
  br label %loop

exit:
  ret void
}

@nikic
Copy link
Contributor

nikic commented Nov 1, 2022

Upstream issue: llvm/llvm-project#58722

@nikic nikic self-assigned this Nov 1, 2022
@bors bors closed this as completed in 7632db0 Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants