1 // RUN: %clang_msan -fsanitize-memory-track-origins=2 %libatomic -DTEST_STORE -O0 %s -o %t && %run %t 2>&1
2 // RUN: %clang_msan -fsanitize-memory-track-origins=0 %libatomic -DTEST_LOAD -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK
3 // RUN: %clang_msan -fsanitize-memory-track-origins=2 %libatomic -DTEST_LOAD -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SHADOW
5 // PPC has no libatomic
6 // UNSUPPORTED: powerpc64-target-arch
7 // UNSUPPORTED: powerpc64le-target-arch
9 #include <sanitizer/msan_interface.h>
10 #include <stdatomic.h>
12 typedef struct __attribute((packed
)) {
16 void copy(i24
*dst
, i24
*src
);
22 __msan_check_mem_is_initialized(&init
, 3);
24 __msan_check_mem_is_initialized(&init
, 3);
27 void copy(i24
*dst
, i24
*src
) {
29 __atomic_load(src
, dst
, __ATOMIC_RELAXED
);
31 // CHECK: MemorySanitizer: use-of-uninitialized-value
32 // CHECK: #0 {{0x[a-f0-9]+}} in main{{.*}}libatomic.c:[[@LINE-8]]
34 // CHECK-SHADOW: Uninitialized value was stored to memory at
35 // CHECK-SHADOW: #0 {{0x[a-f0-9]+}} in copy{{.*}}libatomic.c:[[@LINE-6]]
38 // Store always writes a clean shadow
39 __atomic_store(src
, dst
, __ATOMIC_RELAXED
);