xref: /llvm-project/compiler-rt/test/fuzzer/ExplodeDFSanLabelsTest.cpp (revision ae667c49d228bdd81252ad82a25c67e1a59c8f5c)
1 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2 // See https://llvm.org/LICENSE.txt for license information.
3 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4 
5 // When tracing data flow, explode the number of DFSan labels.
6 #include <cstddef>
7 #include <cstdint>
8 
9 static volatile int sink;
10 
11 __attribute__((noinline))
f(uint8_t a,uint8_t b,uint8_t c,uint8_t d)12 void f(uint8_t a, uint8_t b, uint8_t c, uint8_t d) {
13   if (a == b + 1 && c == d + 2)
14     sink++;
15   if (a == d + 1 && c == b + 2)
16     sink++;
17 }
18 
LLVMFuzzerTestOneInput(const uint8_t * Data,size_t Size)19 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
20   for (size_t a = 0; a < Size; a++)
21     for (size_t b = 0; b < Size; b++)
22       for (size_t c = 0; c < Size; c++)
23         for (size_t d = 0; d < Size; d++)
24           f(Data[a], Data[b], Data[c], Data[d]);
25   return 0;
26 }
27