LLVM  5.0.0
LargeTest.cpp
Go to the documentation of this file.
1 // This file is distributed under the University of Illinois Open Source
2 // License. See LICENSE.TXT for details.
3 
4 // A fuzz target with lots of edges.
5 #include <cstdint>
6 #include <cstdlib>
7 
8 static inline void break_optimization(const void *arg) {
9  __asm__ __volatile__("" : : "r" (arg) : "memory");
10 }
11 
12 #define A \
13  do { \
14  i++; \
15  c++; \
16  if (Data[(i + __LINE__) % Size] == (c % 256)) \
17  break_optimization(Data); \
18  else \
19  break_optimization(0); \
20  } while (0)
21 
22 // for (int i = 0, n = Data[(__LINE__ - 1) % Size] % 16; i < n; i++)
23 
24 #define B do{A; A; A; A; A; A; A; A; A; A; A; A; A; A; A; A; A; A; }while(0)
25 #define C do{B; B; B; B; B; B; B; B; B; B; B; B; B; B; B; B; B; B; }while(0)
26 #define D do{C; C; C; C; C; C; C; C; C; C; C; C; C; C; C; C; C; C; }while(0)
27 #define E do{D; D; D; D; D; D; D; D; D; D; D; D; D; D; D; D; D; D; }while(0)
28 
29 volatile int sink;
30 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
31  if (!Size) return 0;
32  int c = 0;
33  int i = 0;
34  D;
35  return 0;
36 }
37 
static void break_optimization(const void *arg)
Definition: LargeTest.cpp:8
volatile int sink
When an instruction is found to only be used outside of the loop, this function moves it to the exit ...
Definition: LargeTest.cpp:29
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
Definition: LargeTest.cpp:30
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
#define D
Definition: LargeTest.cpp:26