[PATCH] D50482: Added another optimization pass to make vectorizing possible

Emmett Neyman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 8 17:31:40 PDT 2018


emmettneyman updated this revision to Diff 159834.
emmettneyman added a comment.

- Inlined function


Repository:
  rC Clang

https://reviews.llvm.org/D50482

Files:
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp


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
@@ -100,17 +100,29 @@
   if (!M || verifyModule(*M, &errs()))
     ErrorAndExit("Could not parse IR");
 
+  Triple ModuleTriple(M->getTargetTriple());
+  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  std::string E;
+  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, ModuleTriple, E);
+  TargetMachine *Machine =
+      TheTarget->createTargetMachine(M->getTargetTriple(), getCPUStr(),
+                                     getFeaturesStr(), Options, getRelocModel(),
+                                     getCodeModel(), OLvl);
+  std::unique_ptr<TargetMachine> TM(Machine);
   setFunctionAttributes(getCPUStr(), getFeaturesStr(), *M);
-  
+
   legacy::PassManager Passes;
-  Triple ModuleTriple(M->getTargetTriple());
   
   Passes.add(new TargetLibraryInfoWrapperPass(ModuleTriple));
-  Passes.add(createTargetTransformInfoWrapperPass(TargetIRAnalysis()));
+  Passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
+
+  LLVMTargetMachine &LTM = static_cast<LLVMTargetMachine &>(*TM);
+  Passes.add(LTM.createPassConfig(Passes));
+
   Passes.add(createVerifierPass());
 
   AddOptimizationPasses(Passes, OLvl, 0);
-  
+
   // Add a pass that writes the optimized IR to an output stream
   std::string outString;
   raw_string_ostream OS(outString);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50482.159834.patch
Type: text/x-patch
Size: 1552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180809/d3b1154a/attachment.bin>


More information about the llvm-commits mailing list