flang-compiler / classic-flang-llvm-project

LLVM monorepo for integration with classic flang
Other
19 stars 30 forks source link

atomic test failed #91

Open ghost opened 2 years ago

ghost commented 2 years ago

Hi all: The following code snippet is for atomic function test. when using clang(https://github.com/llvm/llvm-project llvm12.0.1), this test passed. but it will failed when using classic-llvm-clang(https://github.com/flang-compiler/classic-flang-llvm-project tag flang_20211215_12x) If we compile the code by classic-llvm-clang, this test will stucked and running forever. clang test.c -o test ./test

#include <sys/types.h>
int main(void) {
    long  n = 0;
    if (!__sync_bool_compare_and_swap(&n, 0, 1))
          return 1;
    if (__sync_fetch_and_add(&n, 1) != 1)
           return 1;
    if (n != 2)
           return 1;
    __sync_synchronize();;
    return 0;
}
ghost commented 2 years ago

This bug was fixed at llvmorg-12.0.1-rc2

https://github.com/llvm/llvm-project/commit/28730bc82ac00125d1f5894464294583abf786ef