Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / msan / libatomic_load_exceptions.cpp
blob83449c01081027c499cc4c3e650894b87a133340
1 // RUN: %clangxx_msan -fexceptions -fsanitize-memory-track-origins=2 %libatomic -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SHADOW
3 // PPC has no libatomic
4 // UNSUPPORTED: powerpc64-target-arch
5 // UNSUPPORTED: powerpc64le-target-arch
7 #include <sanitizer/msan_interface.h>
8 #include <stdatomic.h>
10 typedef struct __attribute((packed)) {
11 uint8_t val[3];
12 } i24;
14 void copy(i24 *dst, i24 *src);
16 int main() {
17 i24 uninit;
18 i24 init = {0};
20 __msan_check_mem_is_initialized(&init, 3);
21 copy(&init, &uninit);
22 __msan_check_mem_is_initialized(&init, 3);
25 void copy(i24 *dst, i24 *src) {
26 try {
27 __atomic_load(src, dst, __ATOMIC_RELAXED);
28 } catch (...) {
32 // CHECK: MemorySanitizer: use-of-uninitialized-value
33 // CHECK: #0 {{0x[a-f0-9]+}} in main{{.*}}libatomic_load_exceptions.cpp:[[@LINE-11]]
35 // CHECK-SHADOW: Uninitialized value was stored to memory at
36 // CHECK-SHADOW: #0 {{0x[a-f0-9]+}} in copy{{.*}}libatomic_load_exceptions.cpp:[[@LINE-9]]