[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:00:28 PDT 2018
emmettneyman updated this revision to Diff 159831.
emmettneyman added a comment.
- minor style fix
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
@@ -77,6 +77,18 @@
std::exit(1);
}
+// Helper function that returns a *TargetMachine, used by OptLLVM
+static TargetMachine* GetTargetMachine(Triple TheTriple, StringRef CPUStr,
+ StringRef FeaturesStr,
+ const TargetOptions &Options,
+ CodeGenOpt::Level OLvl) {
+ std::string E;
+ const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple, E);
+ return TheTarget->createTargetMachine(TheTriple.getTriple(), CPUStr,
+ FeaturesStr, Options, getRelocModel(),
+ getCodeModel(), OLvl);
+}
+
// Helper function to add optimization passes to the TargetMachine at the
// specified optimization level, OptLevel
static void AddOptimizationPasses(legacy::PassManagerBase &MPM,
@@ -100,17 +112,24 @@
if (!M || verifyModule(*M, &errs()))
ErrorAndExit("Could not parse IR");
+ Triple ModuleTriple(M->getTargetTriple());
+ const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+ std::unique_ptr<TargetMachine> TM(GetTargetMachine(ModuleTriple, getCPUStr(),
+ getFeaturesStr(), Options, OLvl));
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 <M = 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.159831.patch
Type: text/x-patch
Size: 2199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180809/01f32969/attachment.bin>
More information about the llvm-commits
mailing list