Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / fuzzer / DeepRecursionTest.cpp
blobaaef38960fa4ea53501bee1511b884cec337fdc6
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
5 // Simple test for a fuzzer. The fuzzer must find the deep recursion.
6 // To generate a crashy input:
7 // for((i=0;i<110;i++)); do echo -n ABCDEFGHIJ >> INPUT; done
8 #include <cstddef>
9 #include <cstdint>
10 #include <cstdlib>
12 static volatile int Sink;
14 void Recursive(const uint8_t *Data, size_t Size, int Depth) {
15 if (Depth > 1000) abort();
16 if (!Size) return;
17 if (*Data == ('A' + Depth % 10))
18 Recursive(Data + 1, Size - 1, Depth + 1);
19 Sink++;
22 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
23 Recursive(Data, Size, 0);
24 return 0;