Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upf32::powi(_,0) broken on raspberry pi (beta and nightly) #37559
Comments
kali
closed this
Nov 3, 2016
kali
reopened this
Nov 3, 2016
TimNN
added
I-wrong
O-ARM
T-compiler
regression-from-stable-to-beta
labels
Nov 3, 2016
This comment has been minimized.
This comment has been minimized.
|
I tried to find the nightlies between which this was introduced, however the best I can do is some time between I can get |
This comment has been minimized.
This comment has been minimized.
|
In case it helps anyone, assembly and ir of the following demo are here: https://gist.github.com/anonymous/a2a13985180e9960579f5f4a5372596a #[inline(never)]
fn foo() -> f32 {
12345.0f32.powi(0)
}
fn main() {
println!("{}", foo());
} |
This comment has been minimized.
This comment has been minimized.
|
Forgot to mention that as far as I can tell, it only impacts the debug builds. -O builds look fine. |
This comment has been minimized.
This comment has been minimized.
|
@kali: At least for my example, when compiling with Edit: Indeed, when preventing llvm from const folding the #[inline(never)]
fn foo(i: i32) -> f32 {
12345.0f32.powi(i)
}
fn main() {
let s = String::new();
println!("{}", foo(s.len() as i32));
} |
This comment has been minimized.
This comment has been minimized.
|
For what it's worth, I can not reproduce it with armv7-apple-ios on current nightly. |
This comment has been minimized.
This comment has been minimized.
|
cc @japaric -- maybe related to the builtins stuff? |
This comment has been minimized.
This comment has been minimized.
|
@japaric if you know the fix, can it be backported to beta in the next day or two? |
This comment has been minimized.
This comment has been minimized.
|
Oh, it's related to optimization, so maybe not intrinsics. |
brson
added
the
I-nominated
label
Nov 3, 2016
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Isn't this a Raspberry Pi? Why is everyone using the armv7 triple? That Pi has an ARMv6 processor in it. (Pi 2+ is ARMv7). @kali Can you post the output of running |
This comment has been minimized.
This comment has been minimized.
|
@japaric: At least I have |
This comment has been minimized.
This comment has been minimized.
|
It's a Pi 2. Envoyé de mon iPhone
|
This comment has been minimized.
This comment has been minimized.
|
I don't have access to it right now to check the abi. It's a fresh raspbian install, and rustup. Envoyé de mon iPhone
|
This comment has been minimized.
This comment has been minimized.
|
Alright, I can reproduce this now via cross-compile + qemu, even inside the range that previously failed due to SIGILL, I'll try to track down the nightlies between which this was introduced. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
triage: P-high Given that ARM/RasbPi are not tier 1, it's not entirely clear how to prioritize this, but it seems like something we should fix sooner rather than later. We haven't assigned anyone from compiler team yet though since it's not clear who would be best to tackle it. @japaric, do you think you can investigate whether it is indeed related to #35021? |
rust-highfive
added
P-high
and removed
I-nominated
labels
Nov 3, 2016
This comment has been minimized.
This comment has been minimized.
|
Alright, so the generated llvm-ir and asm are exactly the same (at least when using the |
This comment has been minimized.
This comment has been minimized.
|
I have disassembled the generated executables and actually found a difference now: In the "good" case, the calculation is deferred to the external In the "bad" case, __powisf2:
0002af00 vmov.f32 s14, #0x1
0002af04 mov r3, r1
0002af06 vmov s15, r0
0002af0a b 0x2af10
0002af0c vmul.f32 s15, s15, s15
0002af10 add.w r2, r3, r3, lsr #31
0002af14 lsls r3, r3, #0x1f
0002af16 it mi
0002af18 vmulmi.f32 s14, s14, s15
0002af1c asrs r3, r2, #0x1
0002af1e bne 0x2af0c
0002af20 cmp r1, #0x0
0002af22 itt lt
0002af24 vmovlt.f32 s15, #0x1
0002af28 vdivlt.f32 s14, s15, s14
0002af2c vmov r0, s14
0002af30 bx lr
Both executables require the same shared libraries:
My current hypothesis (from what I picked up over time, I'm not really an expert here) is that the |
This comment has been minimized.
This comment has been minimized.
|
(The following is 70% guesswork) I've been trying to debug this a bit and think that problem is a calling convention mismatch. The
1 Edit: was previously |
This comment has been minimized.
This comment has been minimized.
That seems likely. It wouldn't be the first time either. We had a compiler-rt implementation that triggered UB and we had to fix its C implementation. And you are right that before the "compiler-rt crate-ification" PR this symbol came from Ideas to fix this:
|
This comment has been minimized.
This comment has been minimized.
|
Holy cow, nice investigation @TimNN! That's only mildly disturbing that making our linking to compiler-rt "more correct" ended up introducing a bug...
The implementation is pretty small and seems like for the arguments in the program above it should trivially return the right value, unfortunately. Compiling with the wrong flags though seems quite possible! If that is indeed the problem then in theory this can wreak havoc with jemalloc and/or any other C code in the world as well, so I'd prefer to dig into if that's the problem before we stop compiling |
This comment has been minimized.
This comment has been minimized.
|
Wow. That was impressive. Thanks a lot @TimNN and the gang. |
brson
added a commit
to brson/rust
that referenced
this issue
Nov 4, 2016
alexcrichton
added a commit
that referenced
this issue
Nov 4, 2016
brson
added a commit
that referenced
this issue
Nov 4, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Nov 4, 2016
jonathandturner
added a commit
to jonathandturner/rust
that referenced
this issue
Nov 5, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Nov 5, 2016
bors
closed this
in
#37586
Nov 6, 2016
This comment has been minimized.
This comment has been minimized.
|
This should be fixed on beta and in 1.13. |
This comment has been minimized.
This comment has been minimized.
|
Can anybody test on the latest beta? |
This comment has been minimized.
This comment has been minimized.
|
Seems to be working in |
TimNN
referenced this issue
Nov 7, 2016
Closed
[beta] librand unreachable pattern on armv7-unknown-linux-gnueabihf #37630
This comment has been minimized.
This comment has been minimized.
|
@TimNN Woo! Thank you for testing! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
ho, boy.
|
This comment has been minimized.
This comment has been minimized.
|
float litterals got impacted somehow...
|
This comment has been minimized.
This comment has been minimized.
|
Should we re-open this ? or is it better to create a new one ? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
ok. |
kali commentedNov 3, 2016
On a rapsberry pi, rust installed through with rustup:
Stable is correct, but beta and nightly are terribly wrong, so with have a regression. It specifically breaks num-bigint tests on raspberry pi.