llvm-project
llvm-project copied to clipboard
Codegen for atomicrmw sub i64 is broken for x86-32
| Bugzilla Link | 14314 |
| Resolution | FIXED |
| Resolved on | Nov 12, 2012 00:49 |
| Version | trunk |
| OS | Linux |
| Blocks | llvm/llvm-project#14265 |
| Attachments | Testcase |
| Reporter | LLVM Bugzilla Contributor |
| CC | @darkbuck |
Extended Description
The following program should should print -1.
#include <stdio.h> #include <stdint.h>
int64_t atomicSub(int64_t *a, int64_t b) { return __sync_fetch_and_sub(a, b); }
int main(int argc, char **argv) { int64_t a = 0; atomicSub(&a, 1); printf("a = %lli\n", a); return 0; }
clang on x86-64 and gcc on all architectures compile the program correctly. clang on x86-32 prints 1. The last working revision of clang was 164820. The bug first appears in 164821 after a checkin from Michael Liao titled, "Re-work X86 code generation of atomic ops with spin-loop."
I have attached LLVM IR for the test case. The LLVM IR is generated correctly in both 164820 and 164821.
Fixed in r167718.