@@ -2062,7 +2062,8 @@ Error LTO::runThinLTO(AddStreamFn AddStream, AddBufferFn AddBuffer,
20622062 ResolvedODR[Mod.first ], ThinLTO.ModuleMap , ThinLTO.ModuleTriples );
20632063 };
20642064
2065- BackendProcess->setup (ModuleMap.size ());
2065+ BackendProcess->setup (ModuleMap.size (),
2066+ RegularLTO.ParallelCodeGenParallelismLevel );
20662067
20672068 if (BackendProcess->getThreadCount () == 1 ||
20682069 BackendProcess->isSensitiveToInputOrder ()) {
@@ -2228,6 +2229,9 @@ class OutOfProcessThinBackend : public CGThinBackend {
22282229 // A unique string to identify the current link.
22292230 SmallString<8 > UID;
22302231
2232+ // The first ReservedTasks entries in the task range are used for Full LTO.
2233+ unsigned ReservedTasks;
2234+
22312235public:
22322236 OutOfProcessThinBackend (
22332237 const Config &Conf, ModuleSummaryIndex &CombinedIndex,
@@ -2244,9 +2248,10 @@ class OutOfProcessThinBackend : public CGThinBackend {
22442248 RemoteOptTool(RemoteOptTool), DistributorPath(Distributor),
22452249 SaveTemps(SaveTemps) {}
22462250
2247- virtual void setup (unsigned MaxTasks) override {
2251+ virtual void setup (unsigned MaxTasks, unsigned ReservedTasks ) override {
22482252 UID = itostr (sys::Process::getProcessId ());
22492253 Jobs.resize ((size_t )MaxTasks);
2254+ this ->ReservedTasks = ReservedTasks;
22502255 }
22512256
22522257 Error start (
@@ -2263,7 +2268,7 @@ class OutOfProcessThinBackend : public CGThinBackend {
22632268 sys::path::append (ObjFilePath, sys::path::stem (ModulePath) + " ." +
22642269 itostr (Task) + " ." + UID + " .native.o" );
22652270
2266- Job &J = Jobs[Task - 1 ]; /* Task 0 is reserved */
2271+ Job &J = Jobs[Task - ReservedTasks];
22672272 J = {Task,
22682273 ModulePath,
22692274 ModuleTriples[ModulePath],
0 commit comments