1// RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 -mllvm -dfsan-fast-16-labels=true %s -o %t && \
2// RUN: %run %t >%t.out 2>&1
3// RUN: FileCheck %s --check-prefix=CHECK < %t.out
4//
5// REQUIRES: x86_64-target-arch
6
7#include <sanitizer/dfsan_interface.h>
8
9__attribute__((noinline)) uint64_t foo(uint64_t x, uint64_t y) { return x + y; }
10
11int main(int argc, char *argv[]) {
12 uint64_t a = 10;
13 uint64_t b = 20;
14 dfsan_set_label(8, &a, sizeof(a));
15 uint64_t c = foo(a, b);
16 for (int i = 0; i < argc; ++i)
17 c += foo(c, b);
18 dfsan_print_origin_trace(&c, NULL);
19}
20
21// CHECK: Taint value 0x8 {{.*}} origin tracking ()
22// CHECK: Origin value: {{.*}}, Taint value was stored to memory at
23// CHECK: #0 {{.*}} in main {{.*}}origin_branch.c:[[@LINE-6]]
24
25// CHECK: Origin value: {{.*}}, Taint value was stored to memory at
26// CHECK: #0 {{.*}} in main {{.*}}origin_branch.c:[[@LINE-11]]
27
28// CHECK: Origin value: {{.*}}, Taint value was created at
29// CHECK: #0 {{.*}} in main {{.*}}origin_branch.c:[[@LINE-15]]
30