Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / dfsan / origin_limit.c
blob2cc7c5ff7123bd580dd6de16c6bef80d4dce3263
1 // RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 %s -o %t
2 //
3 // RUN: %run %t >%t.out 2>&1
4 // RUN: FileCheck %s < %t.out
5 //
6 // RUN: DFSAN_OPTIONS=origin_history_size=2 %run %t >%t.out 2>&1
7 // RUN: FileCheck %s --check-prefix=CHECK2 < %t.out
8 //
9 // RUN: DFSAN_OPTIONS=origin_history_size=0 %run %t >%t.out 2>&1
10 // RUN: FileCheck %s --check-prefix=CHECK0 < %t.out
12 #include <sanitizer/dfsan_interface.h>
14 #include <stdio.h>
16 __attribute__((noinline)) int foo(int a, int b) { return a + b; }
18 int main(int argc, char *argv[]) {
19 int a = 10;
20 dfsan_set_label(8, &a, sizeof(a));
21 int c = 0;
22 for (int i = 0; i < 17; ++i) {
23 c = foo(a, c);
24 printf("%lx", (unsigned long)&c);
26 dfsan_print_origin_trace(&c, NULL);
29 // CHECK: Taint value 0x8 {{.*}} origin tracking ()
30 // CHECK-COUNT 14: Origin value: {{.*}}, Taint value was stored to memory at
31 // CHECK: Origin value: {{.*}}, Taint value was created at
33 // CHECK2: Taint value 0x8 {{.*}} origin tracking ()
34 // CHECK2: Origin value: {{.*}}, Taint value was stored to memory at
35 // CHECK2: Origin value: {{.*}}, Taint value was created at
37 // CHECK0: Taint value 0x8 {{.*}} origin tracking ()
38 // CHECK0-COUNT 16: Origin value: {{.*}}, Taint value was stored to memory at
39 // CHECK0: Origin value: {{.*}}, Taint value was created at