[PATCH] D50194: LLVM Proto Fuzzer - Run Functions on Suite of Inputs

Emmett Neyman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 2 10:58:56 PDT 2018

emmettneyman added inline comments.

Comment at: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp:173
+  int s = getSize((char *) func_ptr);
+  memcpy(mem, func_ptr, s);
morehouse wrote:
> Why do we need to copy the function somewhere else?  Looks very error-prone and unnecessary.  Also makes this patch larger than it needs to be.
I'm copying the functions because otherwise, the generated machine code gets lost as soon as we exit that function's scope. So I'd have to run the functions inside `CreateJITFunction` if I don't copy it.

I thought about doing it this way: moving the code from `RunFuncsOnInputs` to the bottom of `CreateJITFunction` and then comparing the arrays after both calls to `CreateJITFunction` inside `HandleLLVM`. Do you think that would be cleaner?

Comment at: clang/tools/clang-fuzzer/handle-llvm/input_arrays.cpp:30
+  memcpy(b2, InputArrays[b_index], ArraySize * sizeof(int));
+  memcpy(c2, InputArrays[c_index], ArraySize * sizeof(int));
morehouse wrote:
> Do the generated functions ever modify arrays a and b, or just c?  If just c, we can avoid lots of memcpys here.
Right now the generated functions can modify any of the arrays.

  rC Clang


More information about the cfe-commits mailing list