[llvm] r282290 - [gold] Split plugin options controlling ThinLTO and codegen parallelism.

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 23 13:35:19 PDT 2016


Author: tejohnson
Date: Fri Sep 23 15:35:19 2016
New Revision: 282290

URL: http://llvm.org/viewvc/llvm-project?rev=282290&view=rev
Log:
[gold] Split plugin options controlling ThinLTO and codegen parallelism.

Summary:
As suggested in D24826, use different options for ThinLTO backend
parallelism from the option controlling regular LTO code gen
parallelism. They are already split in the LTO API, and this enables
controlling them with different clang options.

Reviewers: pcc, mehdi_amini

Subscribers: dexonsmith, llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D24873

Modified:
    llvm/trunk/test/tools/gold/X86/parallel.ll
    llvm/trunk/tools/gold/gold-plugin.cpp

Modified: llvm/trunk/test/tools/gold/X86/parallel.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/gold/X86/parallel.ll?rev=282290&r1=282289&r2=282290&view=diff
==============================================================================
--- llvm/trunk/test/tools/gold/X86/parallel.ll (original)
+++ llvm/trunk/test/tools/gold/X86/parallel.ll Fri Sep 23 15:35:19 2016
@@ -1,6 +1,6 @@
 ; RUN: llvm-as -o %t.bc %s
 ; RUN: rm -f %t.opt.bc0 %t.opt.bc1 %t.o0 %t.o1
-; RUN: env LD_PRELOAD=%llvmshlibdir/LLVMgold.so %gold -plugin %llvmshlibdir/LLVMgold.so -u foo -u bar -plugin-opt jobs=2 -plugin-opt save-temps -m elf_x86_64 -o %t %t.bc
+; RUN: env LD_PRELOAD=%llvmshlibdir/LLVMgold.so %gold -plugin %llvmshlibdir/LLVMgold.so -u foo -u bar -plugin-opt lto-partitions=2 -plugin-opt save-temps -m elf_x86_64 -o %t %t.bc
 ; RUN: llvm-dis %t.0.5.precodegen.bc -o - | FileCheck --check-prefix=CHECK-BC0 %s
 ; RUN: llvm-dis %t.1.5.precodegen.bc -o - | FileCheck --check-prefix=CHECK-BC1 %s
 ; RUN: llvm-nm %t.o0 | FileCheck --check-prefix=CHECK0 %s

Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=282290&r1=282289&r2=282290&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Fri Sep 23 15:35:19 2016
@@ -118,9 +118,11 @@ namespace options {
   static unsigned OptLevel = 2;
   // Default parallelism of 0 used to indicate that user did not specify.
   // Actual parallelism default value depends on implementation.
-  // Currently, code generation defaults to no parallelism, whereas
-  // ThinLTO uses the hardware_concurrency as the default.
+  // Currently only affects ThinLTO, where the default is the
+  // hardware_concurrency.
   static unsigned Parallelism = 0;
+  // Default regular LTO codegen parallelism (number of partitions).
+  static unsigned ParallelCodeGenParallelismLevel = 1;
 #ifdef NDEBUG
   static bool DisableVerify = true;
 #else
@@ -211,6 +213,10 @@ namespace options {
     } else if (opt.startswith("jobs=")) {
       if (StringRef(opt_ + 5).getAsInteger(10, Parallelism))
         message(LDPL_FATAL, "Invalid parallelism level: %s", opt_ + 5);
+    } else if (opt.startswith("lto-partitions=")) {
+      if (opt.substr(strlen("lto-partitions="))
+              .getAsInteger(10, ParallelCodeGenParallelismLevel))
+        message(LDPL_FATAL, "Invalid codegen partition level: %s", opt_ + 5);
     } else if (opt == "disable-verify") {
       DisableVerify = true;
     } else {
@@ -690,7 +696,6 @@ public:
 static std::unique_ptr<LTO> createLTO() {
   Config Conf;
   ThinBackend Backend;
-  unsigned ParallelCodeGenParallelismLevel = 1;
 
   Conf.CPU = options::mcpu;
   Conf.Options = InitTargetOptionsFromCodeGenFlags();
@@ -704,12 +709,8 @@ static std::unique_ptr<LTO> createLTO()
   Conf.CGOptLevel = getCGOptLevel();
   Conf.DisableVerify = options::DisableVerify;
   Conf.OptLevel = options::OptLevel;
-  if (options::Parallelism) {
-    if (options::thinlto)
-      Backend = createInProcessThinBackend(options::Parallelism);
-    else
-      ParallelCodeGenParallelismLevel = options::Parallelism;
-  }
+  if (options::Parallelism)
+    Backend = createInProcessThinBackend(options::Parallelism);
   if (options::thinlto_index_only) {
     std::string OldPrefix, NewPrefix;
     getThinLTOOldAndNewPrefix(OldPrefix, NewPrefix);
@@ -749,7 +750,7 @@ static std::unique_ptr<LTO> createLTO()
   }
 
   return llvm::make_unique<LTO>(std::move(Conf), Backend,
-                                ParallelCodeGenParallelismLevel);
+                                options::ParallelCodeGenParallelismLevel);
 }
 
 // Write empty files that may be expected by a distributed build




More information about the llvm-commits mailing list