[bazel] Add missing dependencies for a0ef12c64284abf59bc092b2535cce1247d5f9a4
[llvm-project.git] / compiler-rt / test / msan / libatomic.c
blobbe0b4523690a454d4587d1c3ad89dcb93c4283b0
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)) {
13 uint8_t val[3];
14 } i24;
16 void copy(i24 *dst, i24 *src);
18 int main() {
19 i24 uninit;
20 i24 init = {0};
22 __msan_check_mem_is_initialized(&init, 3);
23 copy(&init, &uninit);
24 __msan_check_mem_is_initialized(&init, 3);
27 void copy(i24 *dst, i24 *src) {
28 #ifdef TEST_LOAD
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]]
36 #endif
37 #ifdef TEST_STORE
38 // Store always writes a clean shadow
39 __atomic_store(src, dst, __ATOMIC_RELAXED);
40 #endif