From: Emmett Neyman Date: Thu, 9 Aug 2018 00:58:23 +0000 (+0000) Subject: Added another optimization pass to make vectorizing possible X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ddb318f9c45f115b4e59c9a61e721c421953098;p=clang Added another optimization pass to make vectorizing possible Summary: I noticed that my code wasn't going deep into the loop vectorizer code so added another pass that makes it go further. Reviewers: morehouse, kcc Reviewed By: morehouse Subscribers: cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D50482 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339305 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp b/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp index ff775c1a76..86df06ab8b 100644 --- a/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp +++ b/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp @@ -100,17 +100,29 @@ static std::string OptLLVM(const std::string &IR, CodeGenOpt::Level OLvl) { 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 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 <M = static_cast(*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);