Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / dfsan / flush.c
bloba60335aaa6d7e6d985aeddedea46f9120e15cc07
1 // Tests dfsan_flush().
2 // RUN: %clang_dfsan %s -o %t && %run %t
3 // RUN: %clang_dfsan -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 %s -o %t && %run %t
5 #include <sanitizer/dfsan_interface.h>
6 #include <assert.h>
7 #include <stdlib.h>
9 int global;
11 int main() {
12 int local;
13 int *heap = (int*)malloc(sizeof(int));
15 dfsan_set_label(10, &global, sizeof(global));
16 dfsan_set_label(20, &local, sizeof(local));
17 dfsan_set_label(30, heap, sizeof(*heap));
19 assert(dfsan_get_label(global) == 10);
20 assert(dfsan_get_label(local) == 20);
21 assert(dfsan_get_label(*heap) == 30);
22 #ifdef ORIGIN_TRACKING
23 assert(dfsan_get_origin(global));
24 assert(dfsan_get_origin(local));
25 assert(dfsan_get_origin(*heap));
26 #endif
28 dfsan_flush();
30 assert(dfsan_get_label(global) == 0);
31 assert(dfsan_get_label(local) == 0);
32 assert(dfsan_get_label(*heap) == 0);
33 assert(dfsan_get_origin(global) == 0);
34 assert(dfsan_get_origin(local) == 0);
35 assert(dfsan_get_origin(*heap) == 0);
37 free(heap);