Skip to content

Commit 8923484

Browse files
committed
Support more than one LTO partition.
1 parent 2be4b0c commit 8923484

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

llvm/include/llvm/LTO/LTO.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class ThinBackendProc {
225225
BackendThreadPool(ThinLTOParallelism) {}
226226

227227
virtual ~ThinBackendProc() = default;
228-
virtual void setup(unsigned MaxTasks) {}
228+
virtual void setup(unsigned MaxTasks, unsigned ReservedTasks) {}
229229
virtual Error start(
230230
unsigned Task, BitcodeModule BM,
231231
const FunctionImporter::ImportMapTy &ImportList,

llvm/lib/LTO/LTO.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
22312235
public:
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

Comments
 (0)