[llvm] r280772 - [LTO] Rename variables to be more explicative.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 6 18:08:32 PDT 2016


Author: davide
Date: Tue Sep  6 20:08:31 2016
New Revision: 280772

URL: http://llvm.org/viewvc/llvm-project?rev=280772&view=rev
Log:
[LTO] Rename variables to be more explicative.

Thanks to Mehdi for the suggestion!

Modified:
    llvm/trunk/lib/LTO/LTOBackend.cpp

Modified: llvm/trunk/lib/LTO/LTOBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOBackend.cpp?rev=280772&r1=280771&r2=280772&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOBackend.cpp (original)
+++ llvm/trunk/lib/LTO/LTOBackend.cpp Tue Sep  6 20:08:31 2016
@@ -103,18 +103,19 @@ Error Config::addSaveTemps(std::string O
 namespace {
 
 std::unique_ptr<TargetMachine>
-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<TargetMachine>(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 @@ static void runOldPMPasses(Config &C, Mo
   // 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
@@ -156,9 +157,9 @@ static AddOutputFn getUncachedOutputWrap
   };
 }
 
-void codegen(Config &C, TargetMachine *TM, AddOutputFn AddOutput, unsigned Task,
-             Module &M) {
-  if (C.PreCodeGenModuleHook && !C.PreCodeGenModuleHook(Task, M))
+void codegen(Config &Conf, TargetMachine *TM, AddOutputFn AddOutput,
+             unsigned Task, Module &Mod) {
+  if (Conf.PreCodeGenModuleHook && !Conf.PreCodeGenModuleHook(Task, Mod))
     return;
 
   auto Output = AddOutput(Task);
@@ -167,18 +168,18 @@ void codegen(Config &C, TargetMachine *T
   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<Module> M) {
+                  std::unique_ptr<Module> Mod) {
   ThreadPool CodegenThreadPool(ParallelCodeGenParallelismLevel);
   unsigned ThreadCount = 0;
   const Target *T = &TM->getTarget();
 
   SplitModule(
-      std::move(M), ParallelCodeGenParallelismLevel,
+      std::move(Mod), ParallelCodeGenParallelismLevel,
       [&](std::unique_ptr<Module> 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 @@ void splitCodeGen(Config &C, TargetMachi
       false);
 }
 
-Expected<const Target *> initAndLookupTarget(Config &C, Module &M) {
+Expected<const Target *> 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<StringError>(Msg, inconvertibleErrorCode());
   return T;
@@ -232,23 +233,23 @@ Expected<const Target *> initAndLookupTa
 
 Error lto::backend(Config &C, AddOutputFn AddOutput,
                    unsigned ParallelCodeGenParallelismLevel,
-                   std::unique_ptr<Module> M) {
-  Expected<const Target *> TOrErr = initAndLookupTarget(C, *M);
+                   std::unique_ptr<Module> Mod) {
+  Expected<const Target *> TOrErr = initAndLookupTarget(C, *Mod);
   if (!TOrErr)
     return TOrErr.takeError();
 
   std::unique_ptr<TargetMachine> 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();
 }




More information about the llvm-commits mailing list