Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / dfsan / origin_of_first_taint.c
blobfc582faff3b5fda57d53c7537253e8f407a510b9
1 // RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 %s -o %t && \
2 // RUN: %run %t 2>&1 | FileCheck %s
4 #include <assert.h>
5 #include <sanitizer/dfsan_interface.h>
6 #include <stdio.h>
8 __attribute__((noinline)) uint64_t foo(uint64_t a, uint64_t b) { return a + b; }
10 int main(int argc, char *argv[]) {
11 uint64_t a = 10;
12 uint64_t b = 20;
13 dfsan_set_label(8, &a, sizeof(a));
14 uint64_t c = foo(a, b);
16 dfsan_origin c_orig = dfsan_get_origin(c);
17 fprintf(stderr, "c_orig 0x%x\n", c_orig);
18 // CHECK: c_orig 0x[[#%x,C_ORIG:]]
19 assert(c_orig != 0);
20 dfsan_print_origin_id_trace(c_orig);
21 // CHECK: Origin value: 0x[[#%x,C_ORIG]], Taint value was created at
23 uint64_t d[4] = {1, 2, 3, c};
24 dfsan_origin d_orig = dfsan_read_origin_of_first_taint(d, sizeof(d));
25 fprintf(stderr, "d_orig 0x%x\n", d_orig);
26 // CHECK: d_orig 0x[[#%x,D_ORIG:]]
27 assert(d_orig != 0);
28 dfsan_print_origin_id_trace(d_orig);
29 // CHECK: Origin value: 0x[[#%x,D_ORIG]], Taint value was stored to memory at
30 // CHECK: Origin value: 0x[[#%x,C_ORIG]], Taint value was created at
31 return 0;