Skip to content

Commit d55d8c0

Browse files
committed
[DTLTO][LLVM] Derive the InProcess backend from a base class
Move some setup code and state to a base class. This will allow the DTLTO ThinLTO backend to share this setup code and state by also deriving from this base class.
1 parent 7d0c1c8 commit d55d8c0

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

llvm/lib/LTO/LTO.cpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,25 +1434,23 @@ Error ThinBackendProc::emitFiles(
14341434
}
14351435

14361436
namespace {
1437-
class InProcessThinBackend : public ThinBackendProc {
1437+
class CGThinBackend : public ThinBackendProc {
14381438
protected:
14391439
AddStreamFn AddStream;
1440-
FileCache Cache;
14411440
DenseSet<GlobalValue::GUID> CfiFunctionDefs;
14421441
DenseSet<GlobalValue::GUID> CfiFunctionDecls;
1443-
14441442
bool ShouldEmitIndexFiles;
14451443

14461444
public:
1447-
InProcessThinBackend(
1445+
CGThinBackend(
14481446
const Config &Conf, ModuleSummaryIndex &CombinedIndex,
1449-
ThreadPoolStrategy ThinLTOParallelism,
14501447
const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
1451-
AddStreamFn AddStream, FileCache Cache, lto::IndexWriteCallback OnWrite,
1452-
bool ShouldEmitIndexFiles, bool ShouldEmitImportsFiles)
1448+
AddStreamFn AddStream, lto::IndexWriteCallback OnWrite,
1449+
bool ShouldEmitIndexFiles, bool ShouldEmitImportsFiles,
1450+
ThreadPoolStrategy ThinLTOParallelism)
14531451
: ThinBackendProc(Conf, CombinedIndex, ModuleToDefinedGVSummaries,
14541452
OnWrite, ShouldEmitImportsFiles, ThinLTOParallelism),
1455-
AddStream(std::move(AddStream)), Cache(std::move(Cache)),
1453+
AddStream(std::move(AddStream)),
14561454
ShouldEmitIndexFiles(ShouldEmitIndexFiles) {
14571455
for (auto &Name : CombinedIndex.cfiFunctionDefs())
14581456
CfiFunctionDefs.insert(
@@ -1461,6 +1459,23 @@ class InProcessThinBackend : public ThinBackendProc {
14611459
CfiFunctionDecls.insert(
14621460
GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(Name)));
14631461
}
1462+
};
1463+
1464+
class InProcessThinBackend : public CGThinBackend {
1465+
protected:
1466+
FileCache Cache;
1467+
1468+
public:
1469+
InProcessThinBackend(
1470+
const Config &Conf, ModuleSummaryIndex &CombinedIndex,
1471+
ThreadPoolStrategy ThinLTOParallelism,
1472+
const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
1473+
AddStreamFn AddStream, FileCache Cache, lto::IndexWriteCallback OnWrite,
1474+
bool ShouldEmitIndexFiles, bool ShouldEmitImportsFiles)
1475+
: CGThinBackend(Conf, CombinedIndex, ModuleToDefinedGVSummaries,
1476+
AddStream, OnWrite, ShouldEmitIndexFiles,
1477+
ShouldEmitImportsFiles, ThinLTOParallelism),
1478+
Cache(std::move(Cache)) {}
14641479

14651480
virtual Error runThinLTOBackendThread(
14661481
AddStreamFn AddStream, FileCache Cache, unsigned Task, BitcodeModule BM,

0 commit comments

Comments
 (0)