[llvm-bugs] [Bug 32379] New: 64-bit bitfield and/or miscompiled on ARM
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Mar 22 10:35:18 PDT 2017
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: unassignedbugs at nondot.org
Reporter: arielb1 at mail.tau.ac.il
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170322/96b6c7f0/attachment.html>
More information about the llvm-bugs
mailing list