The ability to specify alignment was recently added, and it's an important property which we should ensure is set as expected by Clang. (Especially before making further changes to Clang's code in this area.) But, because it's on the end of the lines, the existing tests all ignore it. Therefore, update all the tests to also verify the expected alignment for atomicrmw and cmpxchg. While I was in there, I also updated uses of 'load atomic' and 'store atomic', and added the memory ordering, where that was missing.
31 lines
664 B
C++
31 lines
664 B
C++
// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu | FileCheck %s
|
|
|
|
struct AM {
|
|
int f1, f2;
|
|
};
|
|
alignas(8) AM m;
|
|
AM load1() {
|
|
AM am;
|
|
// m is declared to align to 8bytes, so generate load atomic instead
|
|
// of libcall.
|
|
// CHECK-LABEL: @_Z5load1v
|
|
// CHECK: load atomic {{.*}} monotonic, align 8
|
|
__atomic_load(&m, &am, 0);
|
|
return am;
|
|
}
|
|
|
|
struct BM {
|
|
int f1;
|
|
alignas(8) AM f2;
|
|
};
|
|
BM bm;
|
|
AM load2() {
|
|
AM am;
|
|
// BM::f2 is declared to align to 8bytes, so generate load atomic instead
|
|
// of libcall.
|
|
// CHECK-LABEL: @_Z5load2v
|
|
// CHECK: load atomic {{.*}} monotonic, align 8
|
|
__atomic_load(&bm.f2, &am, 0);
|
|
return am;
|
|
}
|