http://bugs.llvm.org/show_bug.cgi?id=32379
Bug ID: 32379
Summary: 64-bit bitfield and/or miscompiled on ARM
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: ARM
Assignee: unassignedb...@nondot.org
Reporter: arie...@mail.tau.ac.il
CC: llvm-bugs@lists.llvm.org
## Versions
This occurs on Debian's 3.9.1, Rust's fork of 3.9.1, and godbolt's 4.0 & trunk.
## STR
$ cat trouble.c
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
__attribute__((noinline))
uint64_t test_function(uint64_t data, bool f1, bool f2) {
if (f1) data &= ~2;
if (f2) data |= 2;
return data;
}
int main() {
int data = (int)test_function(2, false, false);
printf("%d\n", data);
return 0;
}
$ clang-3.9 test.c --target=armv7-unknown-linux-gnueabihf -O
$ ./a.out
0
$
## Expected Result
Code should print 2
## Actual Result
Code prints 0, as the following assembly is emitted:
test_function(unsigned long long, bool, bool):
mov r12, r0
cmp r2, #0
bfc r12, #1, #1
moveq r12, r0
bfi r12, r3, #1, #1
mov r0, r12
bx lr
The `bfi` instruction trashes the original value of r0.
This was originally reported as Rust bug
https://github.com/rust-lang/rust/issues/40593.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs