emmettneyman created this revision.
emmettneyman added reviewers: kcc, morehouse.
Herald added subscribers: cfe-commits, mgorny.

Added corpus of arrays to use as inputs for the functions. Check that the two
functions modify the inputted arrays in the same way.


Repository:
  rC Clang

https://reviews.llvm.org/D50194

Files:
  clang/tools/clang-fuzzer/CMakeLists.txt
  clang/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp
  clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-llvm/fuzzer_initialize.cpp
  clang/tools/clang-fuzzer/handle-llvm/fuzzer_initialize.h
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.h
  clang/tools/clang-fuzzer/handle-llvm/input_arrays.cpp
  clang/tools/clang-fuzzer/handle-llvm/input_arrays.h

Index: clang/tools/clang-fuzzer/handle-llvm/input_arrays.h
===================================================================
--- /dev/null
+++ clang/tools/clang-fuzzer/handle-llvm/input_arrays.h
@@ -0,0 +1,134 @@
+//==-- input_arrays.h - Helper function for LLVM fuzzer inputs -------------==//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Declares helper functions for getting the inputs on which to call the
+// compiled functions.
+//
+//===----------------------------------------------------------------------===//
+
+#include <iostream>
+#include <string.h>
+
+static const int ArraySize = 64;
+static const int NumArrays = 100;
+
+// Declare the arrays that will be fed to the compiled functions
+static int a1[ArraySize];
+static int b1[ArraySize];
+static int c1[ArraySize];
+static int a2[ArraySize];
+static int b2[ArraySize];
+static int c2[ArraySize];
+
+void UpdateArrays();
+
+std::string ArrayToString(int *arr, int s);
+
+// Define a corpus of possible inputs
+static int InputArrays[100][64] =
+{ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+  {0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
+  {1, 1, 0, 0, 1, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
+  {0, 0, 0, 5, 0, 2, 0, 8, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
+  {1, 1, 2, 1, 6, 0, 3, 1, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10},
+  {0, 0, 2, 0, 0, 7, 0, 4, 2, 0, 12, 12, 0, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12},
+  {1, 1, 0, 2, 2, 9, 8, 0, 5, 3, 1, 14, 14, 14, 0, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14},
+  {0, 0, 0, 4, 0, 1, 10, 9, 0, 6, 4, 2, 0, 16, 16, 16, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+  {1, 1, 2, 3, 2, 3, 0, 11, 10, 0, 7, 5, 3, 1, 18, 18, 18, 18, 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18},
+  {0, 0, 2, 5, 4, 0, 2, 13, 12, 11, 0, 8, 6, 4, 2, 0, 20, 20, 20, 20, 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20},
+  {1, 1, 0, 1, 6, 2, 4, 1, 14, 13, 12, 0, 9, 7, 5, 3, 1, 22, 22, 22, 22, 22, 0, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22},
+  {0, 0, 0, 0, 4, 4, 0, 3, 0, 15, 14, 13, 0, 10, 8, 6, 4, 2, 0, 24, 24, 24, 24, 24, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24},
+  {1, 1, 2, 2, 6, 6, 2, 5, 2, 17, 16, 15, 14, 0, 11, 9, 7, 5, 3, 1, 26, 26, 26, 26, 26, 26, 0, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26},
+  {0, 0, 2, 4, 0, 8, 4, 0, 4, 1, 18, 17, 16, 15, 0, 12, 10, 8, 6, 4, 2, 0, 28, 28, 28, 28, 28, 28, 0, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28},
+  {1, 1, 0, 3, 2, 5, 6, 2, 6, 3, 0, 19, 18, 17, 16, 0, 13, 11, 9, 7, 5, 3, 1, 30, 30, 30, 30, 30, 30, 30, 0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30},
+  {0, 0, 0, 5, 0, 7, 8, 4, 0, 5, 2, 21, 20, 19, 18, 17, 0, 14, 12, 10, 8, 6, 4, 2, 0, 32, 32, 32, 32, 32, 32, 32, 0, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32},
+  {1, 1, 2, 1, 2, 9, 10, 6, 2, 7, 4, 1, 22, 21, 20, 19, 18, 0, 15, 13, 11, 9, 7, 5, 3, 1, 34, 34, 34, 34, 34, 34, 34, 34, 0, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34},
+  {0, 0, 2, 0, 4, 1, 6, 8, 4, 0, 6, 3, 0, 23, 22, 21, 20, 19, 0, 16, 14, 12, 10, 8, 6, 4, 2, 0, 36, 36, 36, 36, 36, 36, 36, 36, 0, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36},
+  {1, 1, 0, 2, 6, 3, 8, 10, 6, 2, 8, 5, 2, 25, 24, 23, 22, 21, 20, 0, 17, 15, 13, 11, 9, 7, 5, 3, 1, 38, 38, 38, 38, 38, 38, 38, 38, 38, 0, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38},
+  {0, 0, 0, 4, 4, 0, 10, 12, 8, 4, 0, 7, 4, 1, 26, 25, 24, 23, 22, 21, 0, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 40, 40, 40, 40, 40, 40, 40, 40, 40, 0, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40},
+  {1, 1, 2, 3, 6, 2, 0, 7, 10, 6, 2, 9, 6, 3, 0, 27, 26, 25, 24, 23, 22, 0, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 0, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42},
+  {0, 0, 2, 5, 0, 4, 2, 9, 12, 8, 4, 0, 8, 5, 2, 29, 28, 27, 26, 25, 24, 23, 0, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 0, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44},
+  {1, 1, 0, 1, 2, 6, 4, 11, 14, 10, 6, 2, 10, 7, 4, 1, 30, 29, 28, 27, 26, 25, 24, 0, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 0, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46},
+  {0, 0, 0, 0, 0, 8, 0, 13, 8, 12, 8, 4, 0, 9, 6, 3, 0, 31, 30, 29, 28, 27, 26, 25, 0, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48},
+  {1, 1, 2, 2, 2, 5, 2, 1, 10, 14, 10, 6, 2, 11, 8, 5, 2, 33, 32, 31, 30, 29, 28, 27, 26, 0, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50},
+  {0, 0, 2, 4, 4, 7, 4, 3, 12, 16, 12, 8, 4, 0, 10, 7, 4, 1, 34, 33, 32, 31, 30, 29, 28, 27, 0, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 0, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52},
+  {1, 1, 0, 3, 6, 9, 6, 5, 14, 9, 14, 10, 6, 2, 12, 9, 6, 3, 0, 35, 34, 33, 32, 31, 30, 29, 28, 0, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 0, 54, 54, 54, 54, 54, 54, 54, 54, 54},
+  {0, 0, 0, 5, 4, 1, 8, 0, 0, 11, 16, 12, 8, 4, 0, 11, 8, 5, 2, 37, 36, 35, 34, 33, 32, 31, 30, 29, 0, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 0, 56, 56, 56, 56, 56, 56, 56},
+  {1, 1, 2, 1, 6, 3, 10, 2, 2, 13, 18, 14, 10, 6, 2, 13, 10, 7, 4, 1, 38, 37, 36, 35, 34, 33, 32, 31, 30, 0, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 0, 58, 58, 58, 58, 58},
+  {0, 0, 2, 0, 0, 0, 6, 4, 4, 15, 10, 16, 12, 8, 4, 0, 12, 9, 6, 3, 0, 39, 38, 37, 36, 35, 34, 33, 32, 31, 0, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 0, 60, 60, 60},
+  {1, 1, 0, 2, 2, 2, 8, 6, 6, 17, 12, 18, 14, 10, 6, 2, 14, 11, 8, 5, 2, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 0, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 0, 62},
+  {0, 0, 0, 4, 0, 4, 10, 8, 0, 1, 14, 20, 16, 12, 8, 4, 0, 13, 10, 7, 4, 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 0, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64},
+  {1, 1, 2, 3, 2, 6, 0, 10, 2, 3, 16, 11, 18, 14, 10, 6, 2, 15, 12, 9, 6, 3, 0, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 0, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66},
+  {0, 0, 2, 5, 4, 8, 2, 12, 4, 5, 18, 13, 20, 16, 12, 8, 4, 0, 14, 11, 8, 5, 2, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 0, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68},
+  {1, 1, 0, 1, 6, 5, 4, 7, 6, 7, 0, 15, 22, 18, 14, 10, 6, 2, 16, 13, 10, 7, 4, 1, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 0, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70},
+  {0, 0, 0, 0, 4, 7, 0, 9, 8, 0, 2, 17, 12, 20, 16, 12, 8, 4, 0, 15, 12, 9, 6, 3, 0, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 0, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 72, 72, 72, 72, 72, 72, 72, 72, 72},
+  {1, 1, 2, 2, 6, 9, 2, 11, 10, 2, 4, 19, 14, 22, 18, 14, 10, 6, 2, 17, 14, 11, 8, 5, 2, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 0, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 74, 74, 74, 74, 74, 74, 74, 74},
+  {0, 0, 2, 4, 0, 1, 4, 13, 12, 4, 6, 21, 16, 24, 20, 16, 12, 8, 4, 0, 16, 13, 10, 7, 4, 1, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 0, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 76, 76, 76, 76, 76, 76},
+  {1, 1, 0, 3, 2, 3, 6, 1, 14, 6, 8, 1, 18, 13, 22, 18, 14, 10, 6, 2, 18, 15, 12, 9, 6, 3, 0, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 0, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 78, 78, 78, 78, 78},
+  {0, 0, 0, 5, 0, 0, 8, 3, 8, 8, 0, 3, 20, 15, 24, 20, 16, 12, 8, 4, 0, 17, 14, 11, 8, 5, 2, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 0, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 80, 80, 80},
+  {1, 1, 2, 1, 2, 2, 10, 5, 10, 10, 2, 5, 22, 17, 26, 22, 18, 14, 10, 6, 2, 19, 16, 13, 10, 7, 4, 1, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 0, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 82, 82},
+  {0, 0, 2, 0, 4, 4, 6, 0, 12, 12, 4, 7, 0, 19, 14, 24, 20, 16, 12, 8, 4, 0, 18, 15, 12, 9, 6, 3, 0, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 0, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0},
+  {1, 1, 0, 2, 6, 6, 8, 2, 14, 14, 6, 9, 2, 21, 16, 26, 22, 18, 14, 10, 6, 2, 20, 17, 14, 11, 8, 5, 2, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 0, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3},
+  {0, 0, 0, 4, 4, 8, 10, 4, 0, 16, 8, 0, 4, 23, 18, 28, 24, 20, 16, 12, 8, 4, 0, 19, 16, 13, 10, 7, 4, 1, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 0, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6},
+  {1, 1, 2, 3, 6, 5, 0, 6, 2, 9, 10, 2, 6, 25, 20, 15, 26, 22, 18, 14, 10, 6, 2, 21, 18, 15, 12, 9, 6, 3, 0, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 0, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9},
+  {0, 0, 2, 5, 0, 7, 2, 8, 4, 11, 12, 4, 8, 1, 22, 17, 28, 24, 20, 16, 12, 8, 4, 0, 20, 17, 14, 11, 8, 5, 2, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 0, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12},
+  {1, 1, 0, 1, 2, 9, 4, 10, 6, 13, 14, 6, 10, 3, 24, 19, 30, 26, 22, 18, 14, 10, 6, 2, 22, 19, 16, 13, 10, 7, 4, 1, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 0, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15},
+  {0, 0, 0, 0, 0, 1, 0, 12, 0, 15, 16, 8, 0, 5, 26, 21, 16, 28, 24, 20, 16, 12, 8, 4, 0, 21, 18, 15, 12, 9, 6, 3, 0, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 0, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18},
+  {1, 1, 2, 2, 2, 3, 2, 7, 2, 17, 18, 10, 2, 7, 0, 23, 18, 30, 26, 22, 18, 14, 10, 6, 2, 23, 20, 17, 14, 11, 8, 5, 2, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 0, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21},
+  {0, 0, 2, 4, 4, 0, 4, 9, 4, 1, 10, 12, 4, 9, 2, 25, 20, 32, 28, 24, 20, 16, 12, 8, 4, 0, 22, 19, 16, 13, 10, 7, 4, 1, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 0, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24},
+  {1, 1, 0, 3, 6, 2, 6, 11, 6, 3, 12, 14, 6, 11, 4, 27, 22, 17, 30, 26, 22, 18, 14, 10, 6, 2, 24, 21, 18, 15, 12, 9, 6, 3, 0, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 0, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27},
+  {0, 0, 0, 5, 4, 4, 8, 13, 8, 5, 14, 16, 8, 0, 6, 29, 24, 19, 32, 28, 24, 20, 16, 12, 8, 4, 0, 23, 20, 17, 14, 11, 8, 5, 2, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 0, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30},
+  {1, 1, 2, 1, 6, 6, 10, 1, 10, 7, 16, 18, 10, 2, 8, 1, 26, 21, 34, 30, 26, 22, 18, 14, 10, 6, 2, 25, 22, 19, 16, 13, 10, 7, 4, 1, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 0, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33},
+  {0, 0, 2, 0, 0, 8, 6, 3, 12, 0, 18, 20, 12, 4, 10, 3, 28, 23, 18, 32, 28, 24, 20, 16, 12, 8, 4, 0, 24, 21, 18, 15, 12, 9, 6, 3, 0, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 0, 52, 50, 48, 46, 44, 42, 40, 38, 36},
+  {1, 1, 0, 2, 2, 5, 8, 5, 14, 2, 0, 11, 14, 6, 12, 5, 30, 25, 20, 34, 30, 26, 22, 18, 14, 10, 6, 2, 26, 23, 20, 17, 14, 11, 8, 5, 2, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 0, 53, 51, 49, 47, 45, 43, 41, 39},
+  {0, 0, 0, 4, 0, 7, 10, 0, 8, 4, 2, 13, 16, 8, 0, 7, 0, 27, 22, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 25, 22, 19, 16, 13, 10, 7, 4, 1, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 0, 54, 52, 50, 48, 46, 44, 42},
+  {1, 1, 2, 3, 2, 9, 0, 2, 10, 6, 4, 15, 18, 10, 2, 9, 2, 29, 24, 19, 34, 30, 26, 22, 18, 14, 10, 6, 2, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 0, 55, 53, 51, 49, 47, 45},
+  {0, 0, 2, 5, 4, 1, 2, 4, 12, 8, 6, 17, 20, 12, 4, 11, 4, 31, 26, 21, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 26, 23, 20, 17, 14, 11, 8, 5, 2, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 0, 56, 54, 52, 50, 48},
+  {1, 1, 0, 1, 6, 3, 4, 6, 14, 10, 8, 19, 22, 14, 6, 13, 6, 33, 28, 23, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 0, 57, 55, 53, 51},
+  {0, 0, 0, 0, 4, 0, 0, 8, 0, 12, 0, 21, 12, 16, 8, 0, 8, 1, 30, 25, 20, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 0, 58, 56, 54},
+  {1, 1, 2, 2, 6, 2, 2, 10, 2, 14, 2, 1, 14, 18, 10, 2, 10, 3, 32, 27, 22, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 0, 59, 57},
+  {0, 0, 2, 4, 0, 4, 4, 12, 4, 16, 4, 3, 16, 20, 12, 4, 12, 5, 34, 29, 24, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 0, 60},
+  {1, 1, 0, 3, 2, 6, 6, 7, 6, 9, 6, 5, 18, 22, 14, 6, 14, 7, 0, 31, 26, 21, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 0},
+  {0, 0, 0, 5, 0, 8, 8, 9, 0, 11, 8, 7, 20, 24, 16, 8, 0, 9, 2, 33, 28, 23, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65},
+  {1, 1, 2, 1, 2, 5, 10, 11, 2, 13, 10, 9, 22, 13, 18, 10, 2, 11, 4, 35, 30, 25, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67},
+  {0, 0, 2, 0, 4, 7, 6, 13, 4, 15, 12, 0, 0, 15, 20, 12, 4, 13, 6, 37, 32, 27, 22, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69},
+  {1, 1, 0, 2, 6, 9, 8, 1, 6, 17, 14, 2, 2, 17, 22, 14, 6, 15, 8, 1, 34, 29, 24, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71},
+  {0, 0, 0, 4, 4, 1, 10, 3, 8, 1, 16, 4, 4, 19, 24, 16, 8, 0, 10, 3, 36, 31, 26, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73},
+  {1, 1, 2, 3, 6, 3, 0, 5, 10, 3, 18, 6, 6, 21, 26, 18, 10, 2, 12, 5, 38, 33, 28, 23, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 33, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75},
+  {0, 0, 2, 5, 0, 0, 2, 0, 12, 5, 10, 8, 8, 23, 14, 20, 12, 4, 14, 7, 0, 35, 30, 25, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77},
+  {1, 1, 0, 1, 2, 2, 4, 2, 14, 7, 12, 10, 10, 25, 16, 22, 14, 6, 16, 9, 2, 37, 32, 27, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 34, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79},
+  {0, 0, 0, 0, 0, 4, 0, 4, 8, 0, 14, 12, 0, 1, 18, 24, 16, 8, 0, 11, 4, 39, 34, 29, 24, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 33, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81},
+  {1, 1, 2, 2, 2, 6, 2, 6, 10, 2, 16, 14, 2, 3, 20, 26, 18, 10, 2, 13, 6, 41, 36, 31, 26, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 35, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83},
+  {0, 0, 2, 4, 4, 8, 4, 8, 12, 4, 18, 16, 4, 5, 22, 28, 20, 12, 4, 15, 8, 1, 38, 33, 28, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 34, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85},
+  {1, 1, 0, 3, 6, 5, 6, 10, 14, 6, 0, 18, 6, 7, 24, 15, 22, 14, 6, 17, 10, 3, 40, 35, 30, 25, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 36, 33, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87},
+  {0, 0, 0, 5, 4, 7, 8, 12, 0, 8, 2, 20, 8, 9, 26, 17, 24, 16, 8, 0, 12, 5, 42, 37, 32, 27, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 35, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89},
+  {1, 1, 2, 1, 6, 9, 10, 7, 2, 10, 4, 11, 10, 11, 0, 19, 26, 18, 10, 2, 14, 7, 0, 39, 34, 29, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 37, 34, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91},
+  {0, 0, 2, 0, 0, 1, 6, 9, 4, 12, 6, 13, 12, 0, 2, 21, 28, 20, 12, 4, 16, 9, 2, 41, 36, 31, 26, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 36, 33, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93},
+  {1, 1, 0, 2, 2, 3, 8, 11, 6, 14, 8, 15, 14, 2, 4, 23, 30, 22, 14, 6, 18, 11, 4, 43, 38, 33, 28, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 38, 35, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95},
+  {0, 0, 0, 4, 0, 0, 10, 13, 0, 16, 0, 17, 16, 4, 6, 25, 16, 24, 16, 8, 0, 13, 6, 45, 40, 35, 30, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 37, 34, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97},
+  {1, 1, 2, 3, 2, 2, 0, 1, 2, 9, 2, 19, 18, 6, 8, 27, 18, 26, 18, 10, 2, 15, 8, 1, 42, 37, 32, 27, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 39, 36, 33, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 107, 106, 105, 104, 103, 102, 101, 100, 99},
+  {0, 0, 2, 5, 4, 4, 2, 3, 4, 11, 4, 21, 20, 8, 10, 29, 20, 28, 20, 12, 4, 17, 10, 3, 44, 39, 34, 29, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 38, 35, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2, 109, 108, 107, 106, 105, 104, 103, 102, 101},
+  {1, 1, 0, 1, 6, 6, 4, 5, 6, 13, 6, 1, 22, 10, 12, 1, 22, 30, 22, 14, 6, 19, 12, 5, 46, 41, 36, 31, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 40, 37, 34, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1, 110, 109, 108, 107, 106, 105, 104, 103},
+  {0, 0, 0, 0, 4, 8, 0, 0, 8, 15, 8, 3, 12, 12, 0, 3, 24, 32, 24, 16, 8, 0, 14, 7, 0, 43, 38, 33, 28, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 39, 36, 33, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 111, 110, 109, 108, 107, 106, 105},
+  {1, 1, 2, 2, 6, 5, 2, 2, 10, 17, 10, 5, 14, 14, 2, 5, 26, 17, 26, 18, 10, 2, 16, 9, 2, 45, 40, 35, 30, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 41, 38, 35, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2, 113, 112, 111, 110, 109, 108, 107},
+  {0, 0, 2, 4, 0, 7, 4, 4, 12, 1, 12, 7, 16, 16, 4, 7, 28, 19, 28, 20, 12, 4, 18, 11, 4, 47, 42, 37, 32, 56, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 40, 37, 34, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1, 114, 113, 112, 111, 110, 109},
+  {1, 1, 0, 3, 2, 9, 6, 6, 14, 3, 14, 9, 18, 18, 6, 9, 30, 21, 30, 22, 14, 6, 20, 13, 6, 49, 44, 39, 34, 29, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 42, 39, 36, 33, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 115, 114, 113, 112, 111},
+  {0, 0, 0, 5, 0, 1, 8, 8, 8, 5, 16, 0, 20, 20, 8, 11, 0, 23, 32, 24, 16, 8, 0, 15, 8, 1, 46, 41, 36, 31, 56, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 41, 38, 35, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2, 117, 116, 115, 114, 113},
+  {1, 1, 2, 1, 2, 3, 10, 10, 10, 7, 18, 2, 22, 22, 10, 13, 2, 25, 34, 26, 18, 10, 2, 17, 10, 3, 48, 43, 38, 33, 58, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 43, 40, 37, 34, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1, 118, 117, 116, 115},
+  {0, 0, 2, 0, 4, 0, 6, 12, 12, 0, 10, 4, 0, 24, 12, 0, 4, 27, 18, 28, 20, 12, 4, 19, 12, 5, 50, 45, 40, 35, 30, 56, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 42, 39, 36, 33, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 119, 118, 117},
+  {1, 1, 0, 2, 6, 2, 8, 7, 14, 2, 12, 6, 2, 13, 14, 2, 6, 29, 20, 30, 22, 14, 6, 21, 14, 7, 0, 47, 42, 37, 32, 58, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 44, 41, 38, 35, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2, 121, 120, 119},
+  {0, 0, 0, 4, 4, 4, 10, 9, 0, 4, 14, 8, 4, 15, 16, 4, 8, 31, 22, 32, 24, 16, 8, 0, 16, 9, 2, 49, 44, 39, 34, 60, 56, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 43, 40, 37, 34, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1, 122, 121},
+  {1, 1, 2, 3, 6, 6, 0, 11, 2, 6, 16, 10, 6, 17, 18, 6, 10, 33, 24, 34, 26, 18, 10, 2, 18, 11, 4, 51, 46, 41, 36, 31, 58, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 45, 42, 39, 36, 33, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 123},
+  {0, 0, 2, 5, 0, 8, 2, 13, 4, 8, 18, 12, 8, 19, 20, 8, 12, 1, 26, 36, 28, 20, 12, 4, 20, 13, 6, 53, 48, 43, 38, 33, 60, 56, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 44, 41, 38, 35, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5, 2, 125},
+  {1, 1, 0, 1, 2, 5, 4, 1, 6, 10, 0, 14, 10, 21, 22, 10, 14, 3, 28, 19, 30, 22, 14, 6, 22, 15, 8, 1, 50, 45, 40, 35, 62, 58, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 46, 43, 40, 37, 34, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1},
+  {0, 0, 0, 0, 0, 7, 0, 3, 0, 12, 2, 16, 0, 23, 24, 12, 0, 5, 30, 21, 32, 24, 16, 8, 0, 17, 10, 3, 52, 47, 42, 37, 32, 60, 56, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 45, 42, 39, 36, 33, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3},
+  {1, 1, 2, 2, 2, 9, 2, 5, 2, 14, 4, 18, 2, 25, 26, 14, 2, 7, 32, 23, 34, 26, 18, 10, 2, 19, 12, 5, 54, 49, 44, 39, 34, 62, 58, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 47, 44, 41, 38, 35, 32, 29, 26, 23, 20, 17, 14, 11, 8, 5},
+  {0, 0, 2, 4, 4, 1, 4, 0, 4, 16, 6, 20, 4, 1, 14, 16, 4, 9, 34, 25, 36, 28, 20, 12, 4, 21, 14, 7, 0, 51, 46, 41, 36, 64, 60, 56, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 46, 43, 40, 37, 34, 31, 28, 25, 22, 19, 16, 13, 10, 7},
+  {1, 1, 0, 3, 6, 3, 6, 2, 6, 9, 8, 11, 6, 3, 16, 18, 6, 11, 0, 27, 38, 30, 22, 14, 6, 23, 16, 9, 2, 53, 48, 43, 38, 33, 62, 58, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 48, 45, 42, 39, 36, 33, 30, 27, 24, 21, 18, 15, 12, 9} };
Index: clang/tools/clang-fuzzer/handle-llvm/input_arrays.cpp
===================================================================
--- /dev/null
+++ clang/tools/clang-fuzzer/handle-llvm/input_arrays.cpp
@@ -0,0 +1,42 @@
+//==-- input_arrays.cpp - Helper function for LLVM fuzzer inputs -----------==//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Implements helper functions for getting the inputs on which to call the
+// compiled functions.
+//
+//===----------------------------------------------------------------------===//
+
+#include "input_arrays.h"
+
+#include <stdlib.h>
+
+// Pick three random arrays from the corpus
+// Assign those arrays to be inputs to the functions
+void UpdateArrays() {
+  int a_index = rand() % 100;
+  int b_index = rand() % 100;
+  int c_index = rand() % 100;
+  memcpy(a1, InputArrays[a_index], ArraySize * sizeof(int));
+  memcpy(b1, InputArrays[b_index], ArraySize * sizeof(int));
+  memcpy(c1, InputArrays[c_index], ArraySize * sizeof(int));
+  memcpy(a2, InputArrays[a_index], ArraySize * sizeof(int));
+  memcpy(b2, InputArrays[b_index], ArraySize * sizeof(int));
+  memcpy(c2, InputArrays[c_index], ArraySize * sizeof(int));
+}
+
+// Helper function to convert an array to a string
+// Only called when fuzzer finds a bug
+std::string ArrayToString(int *arr, int s) {
+  std::string array = "";
+  for (int i = 0; i < s; i++) {
+    array += std::to_string(arr[i]);
+    array += ", ";
+  }
+  return array;
+}
Index: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
===================================================================
--- clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -15,6 +15,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "handle_llvm.h"
+#include "input_arrays.h"
 
 #include "llvm/ADT/Triple.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
@@ -48,6 +49,9 @@
 
 using namespace llvm;
 
+// Define a type for the functions that are compiled and executed
+typedef void (*LLVMFunc)(int*, int*, int*, int);
+
 // Helper function to parse command line args and find the optimization level
 static void getOptLevel(const std::vector<const char *> &ExtraArgs,
                               CodeGenOpt::Level &OLvl) {
@@ -68,6 +72,7 @@
   }
 }
 
+// Helper function to print error message and stop the fuzzer
 void ErrorAndExit(std::string message) {
   errs()<< "ERROR: " << message << "\n";
   std::exit(1);
@@ -117,11 +122,26 @@
   return OS.str();
 }
 
-void CreateAndRunJITFun(const std::string &IR, CodeGenOpt::Level OLvl) {
+// Helper function to calculate size of non-null memory region
+int getSize(char *start) {
+  int s = 0;
+  int null = 0;
+  while (null != 8) {
+    if (start[s] == 0)
+      null++;
+    else
+      null = 0;
+    s++;
+  }
+  return s;
+}
+
+// Takes a string of IR and compiles it using LLVM's JIT Engine
+// Copies the compiled function into the memory region mem
+void CreateJITFunc(const std::string &IR, CodeGenOpt::Level OLvl, void *mem) {
   SMDiagnostic Err;
   LLVMContext Context;
-  std::unique_ptr<Module> M = parseIR(MemoryBufferRef(IR, "IR"), Err,
-                                          Context);
+  std::unique_ptr<Module> M = parseIR(MemoryBufferRef(IR, "IR"), Err, Context);
   if (!M)
     ErrorAndExit("Could not parse IR");
 
@@ -148,31 +168,50 @@
   EE->finalizeObject();
   EE->runStaticConstructorsDestructors(false);
 
-  typedef void (*func)(int*, int*, int*, int);
-  func f = reinterpret_cast<func>(EE->getPointerToFunction(EntryFunc)); 
-
-  // Define some dummy arrays to use an input for now
-  int a[] = {1};
-  int b[] = {1};
-  int c[] = {1};
-  f(a, b, c, 1);
+  void *func_ptr = EE->getPointerToFunction(EntryFunc); 
+  int s = getSize((char *) func_ptr);
+  memcpy(mem, func_ptr, s);
+}
 
-  EE->runStaticConstructorsDestructors(true);
+// Takes two functions and runs them each on a suite of inputs
+// Checks to make sure the functions modify inputs in the same way
+void RunFuncsOnInputs(LLVMFunc f1, LLVMFunc f2) {
+  for (int i = 0; i < NumArrays; i++) {
+    UpdateArrays();
+    f1(a1, b1, c1, ArraySize);
+    f2(a2, b2, c2, ArraySize);
+    if (memcmp(a1, a2, sizeof(int) * ArraySize) ||
+        memcmp(b1, b2, sizeof(int) * ArraySize) ||
+        memcmp(c1, c2, sizeof(int) * ArraySize)) {
+      errs() << "A1: " << ArrayToString(a1, ArraySize) << "\n";
+      errs() << "B1: " << ArrayToString(b1, ArraySize) << "\n";
+      errs() << "C1: " << ArrayToString(c1, ArraySize) << "\n";
+      errs() << "A2: " << ArrayToString(a2, ArraySize) << "\n";
+      errs() << "B2: " << ArrayToString(b2, ArraySize) << "\n";
+      errs() << "C2: " << ArrayToString(c2, ArraySize) << "\n";
+      ErrorAndExit("BUG!!");
+    }
+  }
 }
 
 // Main fuzz target called by ExampleClangLLVMProtoFuzzer.cpp
 // Mimics the lli tool to JIT the LLVM IR code and execute it
 void clang_fuzzer::HandleLLVM(const std::string &IR,
-                              const std::vector<const char *> &ExtraArgs) {
+                              const std::vector<const char *> &ExtraArgs,
+                              void *m1, void *m2) {
   // Parse ExtraArgs to set the optimization level
   CodeGenOpt::Level OLvl;
   getOptLevel(ExtraArgs, OLvl);
 
   // First we optimize the IR by running a loop vectorizer pass
   std::string OptIR = OptLLVM(IR, OLvl);
 
-  CreateAndRunJITFun(OptIR, OLvl);
-  CreateAndRunJITFun(IR, CodeGenOpt::None);
-  
+  CreateJITFunc(OptIR, OLvl, m1);
+  CreateJITFunc(IR, CodeGenOpt::None, m2);
+
+  LLVMFunc f1 = (LLVMFunc) m1;
+  LLVMFunc f2 = (LLVMFunc) m2;
+  RunFuncsOnInputs(f1, f2);
+
   return;
 }
Index: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.h
===================================================================
--- clang/tools/clang-fuzzer/handle-llvm/handle_llvm.h
+++ clang/tools/clang-fuzzer/handle-llvm/handle_llvm.h
@@ -19,7 +19,8 @@
 
 namespace clang_fuzzer {
 void HandleLLVM(const std::string &S,
-               const std::vector<const char *> &ExtraArgs);
+                const std::vector<const char *> &ExtraArgs,
+                void *m1, void *m2);
 } // namespace clang_fuzzer
 
 #endif
Index: clang/tools/clang-fuzzer/handle-llvm/fuzzer_initialize.h
===================================================================
--- clang/tools/clang-fuzzer/handle-llvm/fuzzer_initialize.h
+++ clang/tools/clang-fuzzer/handle-llvm/fuzzer_initialize.h
@@ -1,25 +1,22 @@
-//==-- handle_llvm.h - Helper function for Clang fuzzers -------------------==//
+//==-- fuzzer_initialize.h - Fuzz Clang ------------------------------------==//
 //
 //                     The LLVM Compiler Infrastructure
 //
 // This file is distributed under the University of Illinois Open Source
 // License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
-// Defines HandleLLVM for use by the Clang fuzzers.
+// Declares a function that returns the command line arguments for a specific
+// call to the fuzz target. Also declares getter functions for the two regions
+// in memory that will hold the compiled functions.
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_TOOLS_CLANG_FUZZER_HANDLE_LLVM_HANDLELLVM_H
-#define LLVM_CLANG_TOOLS_CLANG_FUZZER_HANDLE_LLVM_HANDLELLVM_H
-
-#include <string>
 #include <vector>
 
 namespace clang_fuzzer {
-void HandleLLVM(const std::string &S,
-               const std::vector<const char *> &ExtraArgs);
-} // namespace clang_fuzzer
-
-#endif
+const std::vector<const char *>& GetCLArgs();
+void *GetRegion1();
+void *GetRegion2();
+}
Index: clang/tools/clang-fuzzer/handle-llvm/fuzzer_initialize.cpp
===================================================================
--- /dev/null
+++ clang/tools/clang-fuzzer/handle-llvm/fuzzer_initialize.cpp
@@ -0,0 +1,80 @@
+//===-- fuzzer_initialize.cpp - Fuzz Clang --------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// The file includes code that sets up the LLVM Proto Fuzzer.
+///
+//===----------------------------------------------------------------------===//
+
+#include "fuzzer_initialize.h"
+
+#include "llvm/InitializePasses.h"
+#include "llvm/PassRegistry.h"
+#include "llvm/Support/TargetSelect.h"
+#include <cstring>
+#include <sys/mman.h>
+
+using namespace clang_fuzzer;
+using namespace llvm;
+
+
+namespace clang_fuzzer {
+
+static std::vector<const char *> CLArgs;
+static void *m1;
+static void *m2;
+
+const std::vector<const char *>& GetCLArgs() {
+  return CLArgs;
+}
+
+void *GetRegion1() {
+  return m1;
+}
+
+void *GetRegion2() {
+  return m2;
+}
+
+}
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+  InitializeAllTargets();
+  InitializeAllTargetMCs();
+  InitializeAllAsmPrinters();
+  InitializeAllAsmParsers();
+  
+  PassRegistry &Registry = *PassRegistry::getPassRegistry();
+  initializeCore(Registry);
+  initializeScalarOpts(Registry);
+  initializeVectorization(Registry);
+  initializeIPO(Registry);
+  initializeAnalysis(Registry);
+  initializeTransformUtils(Registry);
+  initializeInstCombine(Registry);
+  initializeAggressiveInstCombine(Registry);
+  initializeInstrumentation(Registry);
+  initializeTarget(Registry);
+
+  CLArgs.push_back("-O2");
+  for (int I = 1; I < *argc; I++) {
+    if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
+      for (I++; I < *argc; I++)
+        CLArgs.push_back((*argv)[I]);
+      break;
+    }
+  }
+
+  m1 = mmap(NULL, 1000000, PROT_WRITE | PROT_EXEC, MAP_SHARED | MAP_ANON,
+            -1, 0);
+  m2 = mmap(NULL, 1000000, PROT_WRITE | PROT_EXEC, MAP_SHARED | MAP_ANON,
+            -1, 0);
+
+  return 0;
+}
Index: clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
===================================================================
--- clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
+++ clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
@@ -23,7 +23,9 @@
 endif()
 
 add_clang_library(clangHandleLLVM
+  fuzzer_initialize.cpp
   handle_llvm.cpp
+  input_arrays.cpp
 
   DEPENDS
   ${handle_llvm_deps}
Index: clang/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp
===================================================================
--- clang/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp
+++ clang/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp
@@ -15,14 +15,14 @@
 //===----------------------------------------------------------------------===//
 
 #include "cxx_loop_proto.pb.h"
-#include "fuzzer-initialize/fuzzer_initialize.h"
+#include "handle-llvm/fuzzer_initialize.h"
 #include "handle-llvm/handle_llvm.h"
 #include "proto-to-llvm/loop_proto_to_llvm.h"
 #include "src/libfuzzer/libfuzzer_macro.h"
 
 using namespace clang_fuzzer;
 
 DEFINE_BINARY_PROTO_FUZZER(const LoopFunction &input) {
   auto S = LoopFunctionToLLVMString(input);
-  HandleLLVM(S, GetCLArgs());
+  HandleLLVM(S, GetCLArgs(), GetRegion1(), GetRegion2());
 }
Index: clang/tools/clang-fuzzer/CMakeLists.txt
===================================================================
--- clang/tools/clang-fuzzer/CMakeLists.txt
+++ clang/tools/clang-fuzzer/CMakeLists.txt
@@ -79,19 +79,20 @@
     ${ProtobufMutator_LIBRARIES}
     ${PROTOBUF_LIBRARIES}
     ${LLVM_LIB_FUZZING_ENGINE}
-    clangFuzzerInitialize
     )
 
   target_link_libraries(clang-proto-fuzzer
     PRIVATE
     ${COMMON_PROTO_FUZZ_LIBRARIES}
+    clangFuzzerInitialize
     clangHandleCXX
     clangCXXProto
     clangProtoToCXX
     )
   target_link_libraries(clang-loop-proto-fuzzer
     PRIVATE
     ${COMMON_PROTO_FUZZ_LIBRARIES}
+    clangFuzzerInitialize
     clangHandleCXX
     clangCXXLoopProto
     clangLoopProtoToCXX
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to