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

nightly aarch64: broken in debug mode #48673

Closed
SWW13 opened this issue Mar 2, 2018 · 6 comments
Closed

nightly aarch64: broken in debug mode #48673

SWW13 opened this issue Mar 2, 2018 · 6 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.

Comments

@SWW13
Copy link

SWW13 commented Mar 2, 2018

The code below does not run correctly under aarch64 on the nightly compiler in debug mode.
Every other combination works (only tried nightly and stable releases).

I minimized the sample as far as I could and verified it on real hardware.
Sorry for the title, I have no clue how to name this issue.

I tried this code:

#[derive(Debug, PartialEq)]
pub struct B {
    pub b1: u16,
    pub b2: u8,
}

impl B {
    fn new(b1: u16, b2: u8) -> B {
        B { b1, b2 }
    }
}

#[test]
fn welp() {
    assert_eq!(B::new(0xDEAD, 0xFE), B { b1: 0xDEAD, b2: 0xFE });
}

I expected to see this happen:

$ cargo +nightly test
[...]
test welp ... ok

Instead, this happened:

(qemu-aarch64)

$ cargo +nightly test
[...]
test welp ... thread 'welp' panicked at 'assertion failed: `(left == right)`
  left: `B { b1: 0, b2: 0 }`,
 right: `B { b1: 57005, b2: 254 }`', src/lib.rs:15:5

(aarch64 cpu)

  left: `B { b1: 127, b2: 0 }`,
 right: `B { b1: 57005, b2: 254 }`', src/lib.rs:15:5

Meta

You can reproduce this with qemu-user (aarch64) with the following config:

$ cat .cargo/config
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
runner = "qemu-aarch64"
$ LD_LIBRARY_PATH="/usr/aarch64-linux-gnu/lib:$LD_LIBRARY_PATH" cargo +nightly test --target aarch64-unknown-linux-gnu

CPU:

$ lscpu
Architecture:          aarch64
Byte Order:            Little Endian
[...]
$ cat /proc/cpuinfo
[...]
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4
[...]

rustc --version --verbose:

rustc 1.26.0-nightly (3eeb5a665 2018-03-01)
binary: rustc
commit-hash: 3eeb5a665e313c5b281820099e04d4c6c8188b46
commit-date: 2018-03-01
host: x86_64-unknown-linux-gnu
release: 1.26.0-nightly
LLVM version: 6.0

Edit: smaller example

@parched
Copy link
Contributor

parched commented Mar 6, 2018

I narrowed this down a bit to being caused by the LLVM 6 upgrade. I'll try create a minimal LLVM IR repro.

@kennytm kennytm added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. C-bug Category: This is a bug. labels Mar 6, 2018
@parched
Copy link
Contributor

parched commented Mar 6, 2018

Looks like LLVM 6 enables GlobalISel so I tried with RUSTFLAGS="-C llvm-args=-fast-isel" and the problem goes away.

@parched
Copy link
Contributor

parched commented Mar 7, 2018

There's some changes to the AArch64InstructionSelector in #48782 for inserting/extracting 16bit types so hopefully that will fix it.

@nikomatsakis
Copy link
Contributor

triage: P-high

Check-in from compiler team meeting: thanks for the investigative work! We'll keep an eye on this and see what happens when #48782 lands.

@parched
Copy link
Contributor

parched commented Mar 15, 2018

I tested this on the latest nightly and it's fixed, so it seems the upgrade to released LLVM 6.0 indeed did the trick.

@nikomatsakis
Copy link
Contributor

OK, then I'm going to close the issue! 🎷

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. O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.
Projects
None yet
Development

No branches or pull requests

5 participants