Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / dfsan / origin_memset.c
blobbdd3e85e27b2d3b055237ee9ecd479c10a8f2d5f
1 // RUN: %clang_dfsan -gmlt -DOFFSET=0 -mllvm -dfsan-track-origins=1 %s -o %t && \
2 // RUN: %run %t >%t.out 2>&1
3 // RUN: FileCheck %s --check-prefix=CHECK0 < %t.out
4 //
5 // RUN: %clang_dfsan -gmlt -DOFFSET=10 -mllvm -dfsan-track-origins=1 %s -o %t && \
6 // RUN: %run %t >%t.out 2>&1
7 // RUN: FileCheck %s --check-prefix=CHECK10 < %t.out
9 #include <sanitizer/dfsan_interface.h>
11 #include <string.h>
13 int xx[10000];
15 volatile int idx = 30;
17 __attribute__((noinline))
18 void fn_g(int a, int b) {
19 memset(&xx[idx], a, sizeof(a));
20 memset(&xx[idx + 10], b, sizeof(b));
23 __attribute__((noinline))
24 void fn_f(int a, int b) {
25 fn_g(a, b);
28 int main(int argc, char *argv[]) {
29 int volatile z1;
30 int volatile z2;
31 dfsan_set_label(8, (void *)&z1, sizeof(z1));
32 dfsan_set_label(16, (void *)&z2, sizeof(z2));
33 fn_f(z1, z2);
34 dfsan_print_origin_trace(&xx[idx + OFFSET], NULL);
35 return 0;
38 // CHECK0: Taint value 0x8 {{.*}} origin tracking ()
39 // CHECK0: Origin value: {{.*}}, Taint value was created at
41 // CHECK0: #0 {{.*}} in main {{.*}}origin_memset.c:[[@LINE-10]]
43 // CHECK10: Taint value 0x10 {{.*}} origin tracking ()
44 // CHECK10: Origin value: {{.*}}, Taint value was created at
46 // CHECK10: #0 {{.*}} in main {{.*}}origin_memset.c:[[@LINE-14]]