llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Codegen for atomicrmw sub i64 is broken for x86-32

Open llvmbot opened this issue 14 years ago • 1 comments

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.

llvmbot avatar Nov 11 '12 03:11 llvmbot

Fixed in r167718.

darkbuck avatar Nov 12 '12 08:11 darkbuck