Add GWP-ASan fuzz target to compiler-rt/tools.

Summary:
@eugenis to approve addition of //compiler-rt/tools.
@pree-jackie please confirm that this WFY.

D66494 introduced the GWP-ASan stack_trace_compressor_fuzzer. Building fuzz
targets in compiler-rt is a new affair, and has some challenges:
- If the host compiler doesn't have compiler-rt, the -fsanitize=fuzzer may not
  be able to link against `libclang_rt.fuzzer*`.
- Things in compiler-rt generally aren't built when you want to build with
  sanitizers using `-DLLVM_USE_SANITIZER`. This tricky to work around, so
  we create the new tools directory so that we can build fuzz targets with
  sanitizers. This has the added bonus of fixing the problem above as well, as
  we can now just guard the fuzz target build to only be done with
  `-DLLVM_USE_SANITIZE_COVERAGE=On`.

Reviewers: eugenis, pree-jackie

Reviewed By: eugenis, pree-jackie

Subscribers: dberris, mgorny, #sanitizers, llvm-commits, eugenis, pree-jackie, lebedev.ri, vitalybuka, morehouse

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D66776

llvm-svn: 370094
GitOrigin-RevId: ae56e593b90c61eda160d03398e953cc5c6037b3
diff --git a/stack_trace_compressor_fuzzer.cpp b/stack_trace_compressor_fuzzer.cpp
deleted file mode 100644
index aa57fda..0000000
--- a/stack_trace_compressor_fuzzer.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <cstddef>
-#include <cstdint>
-#include <cstdio>
-#include <cstdlib>
-#include <vector>
-
-#include "gwp_asan/stack_trace_compressor.h"
-
-constexpr size_t kBytesForLargestVarInt = (sizeof(uintptr_t) * 8) / 7 + 1;
-
-extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
-  size_t BufferSize = kBytesForLargestVarInt * Size / sizeof(uintptr_t);
-  std::vector<uint8_t> Buffer(BufferSize);
-  std::vector<uint8_t> Buffer2(BufferSize);
-
-  // Unpack the fuzz bytes.
-  gwp_asan::compression::unpack(Data, Size,
-                                reinterpret_cast<uintptr_t *>(Buffer2.data()),
-                                BufferSize / sizeof(uintptr_t));
-
-  // Pack the fuzz bytes.
-  size_t BytesWritten = gwp_asan::compression::pack(
-      reinterpret_cast<const uintptr_t *>(Data), Size / sizeof(uintptr_t),
-      Buffer.data(), BufferSize);
-
-  // Unpack the compressed buffer.
-  size_t DecodedElements = gwp_asan::compression::unpack(
-      Buffer.data(), BytesWritten,
-      reinterpret_cast<uintptr_t *>(Buffer2.data()),
-      BufferSize / sizeof(uintptr_t));
-
-  // Ensure that every element was encoded and decoded properly.
-  if (DecodedElements != Size / sizeof(uintptr_t))
-    abort();
-
-  // Ensure that the compression and uncompression resulted in the same trace.
-  const uintptr_t *FuzzPtrs = reinterpret_cast<const uintptr_t *>(Data);
-  const uintptr_t *DecodedPtrs =
-      reinterpret_cast<const uintptr_t *>(Buffer2.data());
-  for (size_t i = 0; i < Size / sizeof(uintptr_t); ++i) {
-    if (FuzzPtrs[i] != DecodedPtrs[i]) {
-      fprintf(stderr, "FuzzPtrs[%zu] != DecodedPtrs[%zu] (0x%zx vs. 0x%zx)", i,
-              i, FuzzPtrs[i], DecodedPtrs[i]);
-      abort();
-    }
-  }
-
-  return 0;
-}