llvm.org GIT mirror llvm / 468ae9f
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282290 91177308-0d34-0410-b5e6-96231b3b80d8 Teresa Johnson 4 years ago
2 changed file(s) with 12 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llvm-as -o %t.bc %s
11 ; RUN: rm -f %t.opt.bc0 %t.opt.bc1 %t.o0 %t.o1
2 ; 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
2 ; 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
33 ; RUN: llvm-dis %t.0.5.precodegen.bc -o - | FileCheck --check-prefix=CHECK-BC0 %s
44 ; RUN: llvm-dis %t.1.5.precodegen.bc -o - | FileCheck --check-prefix=CHECK-BC1 %s
55 ; RUN: llvm-nm %t.o0 | FileCheck --check-prefix=CHECK0 %s
117117 static unsigned OptLevel = 2;
118118 // Default parallelism of 0 used to indicate that user did not specify.
119119 // Actual parallelism default value depends on implementation.
120 // Currently, code generation defaults to no parallelism, whereas
121 // ThinLTO uses the hardware_concurrency as the default.
120 // Currently only affects ThinLTO, where the default is the
121 // hardware_concurrency.
122122 static unsigned Parallelism = 0;
123 // Default regular LTO codegen parallelism (number of partitions).
124 static unsigned ParallelCodeGenParallelismLevel = 1;
123125 #ifdef NDEBUG
124126 static bool DisableVerify = true;
125127 #else
210212 } else if (opt.startswith("jobs=")) {
211213 if (StringRef(opt_ + 5).getAsInteger(10, Parallelism))
212214 message(LDPL_FATAL, "Invalid parallelism level: %s", opt_ + 5);
215 } else if (opt.startswith("lto-partitions=")) {
216 if (opt.substr(strlen("lto-partitions="))
217 .getAsInteger(10, ParallelCodeGenParallelismLevel))
218 message(LDPL_FATAL, "Invalid codegen partition level: %s", opt_ + 5);
213219 } else if (opt == "disable-verify") {
214220 DisableVerify = true;
215221 } else {
689695 static std::unique_ptr createLTO() {
690696 Config Conf;
691697 ThinBackend Backend;
692 unsigned ParallelCodeGenParallelismLevel = 1;
693698
694699 Conf.CPU = options::mcpu;
695700 Conf.Options = InitTargetOptionsFromCodeGenFlags();
703708 Conf.CGOptLevel = getCGOptLevel();
704709 Conf.DisableVerify = options::DisableVerify;
705710 Conf.OptLevel = options::OptLevel;
706 if (options::Parallelism) {
707 if (options::thinlto)
708 Backend = createInProcessThinBackend(options::Parallelism);
709 else
710 ParallelCodeGenParallelismLevel = options::Parallelism;
711 }
711 if (options::Parallelism)
712 Backend = createInProcessThinBackend(options::Parallelism);
712713 if (options::thinlto_index_only) {
713714 std::string OldPrefix, NewPrefix;
714715 getThinLTOOldAndNewPrefix(OldPrefix, NewPrefix);
748749 }
749750
750751 return llvm::make_unique(std::move(Conf), Backend,
751 ParallelCodeGenParallelismLevel);
752 options::ParallelCodeGenParallelismLevel);
752753 }
753754
754755 // Write empty files that may be expected by a distributed build