Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / sanitizer_coverage_trace_loads_stores.cpp
blobdd9ef53a4498b76f83c3a347c1a5404df7ae867c
1 // Tests -fsanitize-coverage=trace-pc,trace-loads,trace-stores
2 //
3 // REQUIRES: has_sancovcc,stable-runtime,x86_64
4 //
5 // RUN: %clangxx -O0 %s -fsanitize-coverage=trace-pc,trace-loads,trace-stores -o %t
6 // RUN: %run %t 2>&1 | FileCheck %s
8 #include <stdint.h>
9 #include <stdio.h>
11 extern "C" {
12 void __sanitizer_cov_load1(uint8_t *addr) { printf("load1: %p\n", addr); }
13 void __sanitizer_cov_load2(uint16_t *addr) { printf("load2: %p\n", addr); }
14 void __sanitizer_cov_load4(uint32_t *addr) { printf("load4: %p\n", addr); }
15 void __sanitizer_cov_load8(uint64_t *addr) { printf("load8: %p\n", addr); }
16 void __sanitizer_cov_load16(__int128 *addr) { printf("load16: %p\n", addr); }
18 void __sanitizer_cov_store1(uint8_t *addr) { printf("store1: %p\n", addr); }
19 void __sanitizer_cov_store2(uint16_t *addr) { printf("store2: %p\n", addr); }
20 void __sanitizer_cov_store4(uint32_t *addr) { printf("store4: %p\n", addr); }
21 void __sanitizer_cov_store8(uint64_t *addr) { printf("store8: %p\n", addr); }
22 void __sanitizer_cov_store16(__int128 *addr) { printf("store16: %p\n", addr); }
25 uint8_t var1;
26 uint16_t var2;
27 uint32_t var4;
28 uint64_t var8;
29 __int128 var16;
30 static volatile int sink;
32 int main() {
33 printf("var1: %p\n", &var1);
34 sink = var1;
35 var1 = 42;
36 // CHECK: var1: [[ADDR:0x.*]]
37 // CHECK: load1: [[ADDR]]
38 // CHECK: store1: [[ADDR]]
40 printf("var2: %p\n", &var2);
41 sink = var2;
42 var2 = 42;
43 // CHECK: var2: [[ADDR:0x.*]]
44 // CHECK: load2: [[ADDR]]
45 // CHECK: store2: [[ADDR]]
47 printf("var4: %p\n", &var4);
48 sink = var4;
49 var4 = 42;
50 // CHECK: var4: [[ADDR:0x.*]]
51 // CHECK: load4: [[ADDR]]
52 // CHECK: store4: [[ADDR]]
54 printf("var8: %p\n", &var8);
55 sink = var8;
56 var8 = 42;
57 // CHECK: var8: [[ADDR:0x.*]]
58 // CHECK: load8: [[ADDR]]
59 // CHECK: store8: [[ADDR]]
61 printf("var16: %p\n", &var16);
62 sink = var16;
63 var16 = 42;
64 // CHECK: var16: [[ADDR:0x.*]]
65 // CHECK: load16: [[ADDR]]
66 // CHECK: store16: [[ADDR]]
67 printf("PASS\n");