diff options
| author | Igor Laevsky <igmyrj@gmail.com> | 2017-11-16 15:23:08 +0000 | 
|---|---|---|
| committer | Igor Laevsky <igmyrj@gmail.com> | 2017-11-16 15:23:08 +0000 | 
| commit | e714ef49afef7fc2d6f478974acf2c49860d05dc (patch) | |
| tree | 38559147b66733ba6f1cf136f283fb8df69d7cb6 /llvm/tools/llvm-opt-fuzzer | |
| parent | c3347d4247cf69d1c5db71c8b9067198119163a6 (diff) | |
| download | bcm5719-llvm-e714ef49afef7fc2d6f478974acf2c49860d05dc.tar.gz bcm5719-llvm-e714ef49afef7fc2d6f478974acf2c49860d05dc.zip | |
[FuzzMutate] NFC. Move parseModule and writeModule from llvm-isel-fuzzer into FuzzMutate.
This is to be able to reuse them in the llvm-opt-fuzzer.
llvm-svn: 318407
Diffstat (limited to 'llvm/tools/llvm-opt-fuzzer')
| -rw-r--r-- | llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp | 36 | 
1 files changed, 0 insertions, 36 deletions
| diff --git a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp index 1bbfa5b148b..7ca1d93d70d 100644 --- a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp +++ b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp @@ -37,42 +37,6 @@ static cl::opt<std::string> PassPipeline(  static std::unique_ptr<IRMutator> Mutator;  static std::unique_ptr<TargetMachine> TM; -// This function is mostly copied from the llvm-isel-fuzzer. -// TODO: Move this into FuzzMutate library and reuse. -static std::unique_ptr<Module> parseModule(const uint8_t *Data, size_t Size, -                                           LLVMContext &Context) { - -  if (Size <= 1) -    // We get bogus data given an empty corpus - just create a new module. -    return llvm::make_unique<Module>("M", Context); - -  auto Buffer = MemoryBuffer::getMemBuffer( -      StringRef(reinterpret_cast<const char *>(Data), Size), "Fuzzer input", -      /*RequiresNullTerminator=*/false); - -  SMDiagnostic Err; -  auto M = parseBitcodeFile(Buffer->getMemBufferRef(), Context); -  if (Error E = M.takeError()) { -    errs() << toString(std::move(E)) << "\n"; -    return nullptr; -  } -  return std::move(M.get()); -} - -// This function is copied from the llvm-isel-fuzzer. -// TODO: Move this into FuzzMutate library and reuse. -static size_t writeModule(const Module &M, uint8_t *Dest, size_t MaxSize) { -  std::string Buf; -  { -    raw_string_ostream OS(Buf); -    WriteBitcodeToFile(&M, OS); -  } -  if (Buf.size() > MaxSize) -      return 0; -  memcpy(Dest, Buf.data(), Buf.size()); -  return Buf.size(); -} -  std::unique_ptr<IRMutator> createOptMutator() {    std::vector<TypeGetter> Types{        Type::getInt1Ty,  Type::getInt8Ty,  Type::getInt16Ty, Type::getInt32Ty, | 

