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

Aarch64 LLVM internal error "Both operands to a binary operator are not of the same type" #104099

Closed
ogoffart opened this issue Nov 7, 2022 · 9 comments · Fixed by #105415 or #106406
Closed
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

@ogoffart
Copy link
Contributor

ogoffart commented Nov 7, 2022

Our CI system building artifact for aarch64 started to fail with the release of Rust 1.65

I tried to reduce the bug a bit:

main.rs

fn main() {

    let mut fontdb = fontdb::Database::new();
    fontdb.load_system_fonts();
    fontdb.query(&fontdb::Query { families: &[fontdb::Family::Name("xxx")], ..Default::default() })
        .and_then(|face_id| {
            fontdb.with_face_data(face_id, |_face_data, _face_index| {
                fontdue::Font::from_bytes( b"sfqsqsfqd".as_slice(), fontdue::FontSettings::default())
            })
    });

    let  fonts = Vec::<fontdb::ID>::new();
    let face_id = fonts.into_iter().next().unwrap();
    fontdb .with_face_data(face_id, |_font_data, _face_index| {
        fontdue::Font::from_bytes(b"".as_slice(), fontdue::FontSettings::default())
    });
}

Cargo.toml dependencies

[dependencies]
fontdue = "0.7.2"
fontdb = "0.9.3"

[profile.release]
lto = true

Build with

cargo build --release --target aarch64-unknown-linux-gnu

(same with --target aarch64-apple-darwin)

Since Rust 1.65, we get this error:

Both operands to a binary operator are not of the same type!
  %2414 = xor i64 %2413, i32 4
in function _ZN7fontdue4font4Font10from_bytes17h0d1adf483f24d13bE
LLVM ERROR: Broken function found, compilation aborted!

Can still be reproduced in nightly

@ogoffart ogoffart 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 Nov 7, 2022
@nikic nikic added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Nov 7, 2022
@nikic
Copy link
Contributor

nikic commented Nov 7, 2022

I wasn't able to reproduce this (on either stable or nightly).

@ogoffart
Copy link
Contributor Author

ogoffart commented Nov 7, 2022

You're right, trying in a fresh project i couldn't reproduce. I realized the original Cargo.toml also contained a lto=true that was also necessary
I edited the original description to add

[profile.release]
lto = true

Thanks for looking into this.

@ogoffart
Copy link
Contributor Author

ogoffart commented Nov 7, 2022

Also, contrary to what i wrote initially, the bug appeared first in 1.65 (and not 1.64)

@nikic
Copy link
Contributor

nikic commented Nov 7, 2022

Thanks, I can reproduce the issue now. Reduced test case:

; RUN: llc < %s
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(i8 %arg) {
  %arg.ext = zext i8 %arg to i64
  %trunc = trunc i64 %arg.ext to i3
  %switch.tableidx = xor i3 %trunc, 1
  %switch.maskindex = zext i3 %trunc to i8
  %switch.lobit = icmp ne i8 %switch.maskindex, 0
  call void @llvm.assume(i1 %switch.lobit)
  %ext = zext i3 %switch.tableidx to i64
  ret void
}

declare void @llvm.assume(i1)

@nikic
Copy link
Contributor

nikic commented Nov 7, 2022

Upstream issue: llvm/llvm-project#58843

@nikic nikic self-assigned this Nov 7, 2022
@fenhl
Copy link
Contributor

fenhl commented Nov 17, 2022

The upstream issue appears to be fixed. What needs to be done now to apply this fix?

@fenhl
Copy link
Contributor

fenhl commented Dec 16, 2022

I can still reproduce this on 1.68.0-nightly (ec56537 2022-12-15).

@nikic nikic reopened this Dec 16, 2022
@nikic
Copy link
Contributor

nikic commented Dec 16, 2022

Can confirm that the issue still exists.

@nikic
Copy link
Contributor

nikic commented Dec 16, 2022

New upstream issue: llvm/llvm-project#59554

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.

3 participants