Index: lib/LTO/LTOBackend.cpp =================================================================== --- lib/LTO/LTOBackend.cpp +++ lib/LTO/LTOBackend.cpp @@ -103,18 +103,19 @@ namespace { std::unique_ptr -createTargetMachine(Config &C, StringRef TheTriple, const Target *TheTarget) { +createTargetMachine(Config &Conf, StringRef TheTriple, + const Target *TheTarget) { SubtargetFeatures Features; Features.getDefaultSubtargetFeatures(Triple(TheTriple)); - for (const std::string &A : C.MAttrs) + for (const std::string &A : Conf.MAttrs) Features.AddFeature(A); return std::unique_ptr(TheTarget->createTargetMachine( - TheTriple, C.CPU, Features.getString(), C.Options, C.RelocModel, - C.CodeModel, C.CGOptLevel)); + TheTriple, Conf.CPU, Features.getString(), Conf.Options, Conf.RelocModel, + Conf.CodeModel, Conf.CGOptLevel)); } -static void runOldPMPasses(Config &C, Module &M, TargetMachine *TM, +static void runOldPMPasses(Config &Conf, Module &Mod, TargetMachine *TM, bool IsThinLto) { legacy::PassManager passes; passes.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis())); @@ -125,22 +126,22 @@ // Unconditionally verify input since it is not verified before this // point and has unknown origin. PMB.VerifyInput = true; - PMB.VerifyOutput = !C.DisableVerify; + PMB.VerifyOutput = !Conf.DisableVerify; PMB.LoopVectorize = true; PMB.SLPVectorize = true; - PMB.OptLevel = C.OptLevel; + PMB.OptLevel = Conf.OptLevel; if (IsThinLto) PMB.populateThinLTOPassManager(passes); else PMB.populateLTOPassManager(passes); - passes.run(M); + passes.run(Mod); } -bool opt(Config &C, TargetMachine *TM, unsigned Task, Module &M, +bool opt(Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod, bool IsThinLto) { - M.setDataLayout(TM->createDataLayout()); - runOldPMPasses(C, M, TM, IsThinLto); - return !C.PostOptModuleHook || C.PostOptModuleHook(Task, M); + Mod.setDataLayout(TM->createDataLayout()); + runOldPMPasses(Conf, Mod, TM, IsThinLto); + return !Conf.PostOptModuleHook || Conf.PostOptModuleHook(Task, Mod); } /// Monolithic LTO does not support caching (yet), this is a convenient wrapper @@ -157,8 +158,8 @@ } void codegen(Config &C, TargetMachine *TM, AddOutputFn AddOutput, unsigned Task, - Module &M) { - if (C.PreCodeGenModuleHook && !C.PreCodeGenModuleHook(Task, M)) + Module &Mod) { + if (C.PreCodeGenModuleHook && !C.PreCodeGenModuleHook(Task, Mod)) return; auto Output = AddOutput(Task); @@ -167,18 +168,18 @@ if (TM->addPassesToEmitFile(CodeGenPasses, *OS, TargetMachine::CGFT_ObjectFile)) report_fatal_error("Failed to setup codegen"); - CodeGenPasses.run(M); + CodeGenPasses.run(Mod); } void splitCodeGen(Config &C, TargetMachine *TM, AddOutputFn AddOutput, unsigned ParallelCodeGenParallelismLevel, - std::unique_ptr M) { + std::unique_ptr Mod) { ThreadPool CodegenThreadPool(ParallelCodeGenParallelismLevel); unsigned ThreadCount = 0; const Target *T = &TM->getTarget(); SplitModule( - std::move(M), ParallelCodeGenParallelismLevel, + std::move(Mod), ParallelCodeGenParallelismLevel, [&](std::unique_ptr MPart) { // We want to clone the module in a new context to multi-thread the // codegen. We do it by serializing partition modules to bitcode @@ -215,14 +216,14 @@ false); } -Expected initAndLookupTarget(Config &C, Module &M) { +Expected initAndLookupTarget(Config &C, Module &Mod) { if (!C.OverrideTriple.empty()) - M.setTargetTriple(C.OverrideTriple); - else if (M.getTargetTriple().empty()) - M.setTargetTriple(C.DefaultTriple); + Mod.setTargetTriple(C.OverrideTriple); + else if (Mod.getTargetTriple().empty()) + Mod.setTargetTriple(C.DefaultTriple); std::string Msg; - const Target *T = TargetRegistry::lookupTarget(M.getTargetTriple(), Msg); + const Target *T = TargetRegistry::lookupTarget(Mod.getTargetTriple(), Msg); if (!T) return make_error(Msg, inconvertibleErrorCode()); return T; @@ -232,23 +233,23 @@ Error lto::backend(Config &C, AddOutputFn AddOutput, unsigned ParallelCodeGenParallelismLevel, - std::unique_ptr M) { - Expected TOrErr = initAndLookupTarget(C, *M); + std::unique_ptr Mod) { + Expected TOrErr = initAndLookupTarget(C, *Mod); if (!TOrErr) return TOrErr.takeError(); std::unique_ptr TM = - createTargetMachine(C, M->getTargetTriple(), *TOrErr); + createTargetMachine(C, Mod->getTargetTriple(), *TOrErr); if (!C.CodeGenOnly) - if (!opt(C, TM.get(), 0, *M, /*IsThinLto=*/false)) + if (!opt(C, TM.get(), 0, *Mod, /*IsThinLto=*/false)) return Error(); if (ParallelCodeGenParallelismLevel == 1) { - codegen(C, TM.get(), getUncachedOutputWrapper(AddOutput, 0), 0, *M); + codegen(C, TM.get(), getUncachedOutputWrapper(AddOutput, 0), 0, *Mod); } else { splitCodeGen(C, TM.get(), AddOutput, ParallelCodeGenParallelismLevel, - std::move(M)); + std::move(Mod)); } return Error(); }