From 767e1457d89dba9f6cc41f752b3d3778d4ef3ea0 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Tue, 6 Sep 2016 03:23:45 +0000 Subject: [PATCH] [LTO] Constify (NFC) llvm-svn: 280687 --- llvm/lib/LTO/LTO.cpp | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 597cc04..f495774 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -477,11 +477,11 @@ class lto::ThinBackendProc { protected: Config &Conf; ModuleSummaryIndex &CombinedIndex; - StringMap &ModuleToDefinedGVSummaries; + const StringMap &ModuleToDefinedGVSummaries; public: ThinBackendProc(Config &Conf, ModuleSummaryIndex &CombinedIndex, - StringMap &ModuleToDefinedGVSummaries) + const StringMap &ModuleToDefinedGVSummaries) : Conf(Conf), CombinedIndex(CombinedIndex), ModuleToDefinedGVSummaries(ModuleToDefinedGVSummaries) {} @@ -503,10 +503,11 @@ class InProcessThinBackend : public ThinBackendProc { std::mutex ErrMu; public: - InProcessThinBackend(Config &Conf, ModuleSummaryIndex &CombinedIndex, - unsigned ThinLTOParallelismLevel, - StringMap &ModuleToDefinedGVSummaries, - AddOutputFn AddOutput) + InProcessThinBackend( + Config &Conf, ModuleSummaryIndex &CombinedIndex, + unsigned ThinLTOParallelismLevel, + const StringMap &ModuleToDefinedGVSummaries, + AddOutputFn AddOutput) : ThinBackendProc(Conf, CombinedIndex, ModuleToDefinedGVSummaries), BackendThreadPool(ThinLTOParallelismLevel), AddOutput(std::move(AddOutput)) {} @@ -551,13 +552,16 @@ public: const std::map &ResolvedODR, MapVector &ModuleMap) override { StringRef ModulePath = MBRef.getBufferIdentifier(); + assert(ModuleToDefinedGVSummaries.count(ModulePath)); + const GVSummaryMapTy &DefinedGlobals = + ModuleToDefinedGVSummaries.find(ModulePath)->second; BackendThreadPool.async( [=](MemoryBufferRef MBRef, ModuleSummaryIndex &CombinedIndex, const FunctionImporter::ImportMapTy &ImportList, const FunctionImporter::ExportSetTy &ExportList, const std::map &ResolvedODR, - GVSummaryMapTy &DefinedGlobals, + const GVSummaryMapTy &DefinedGlobals, MapVector &ModuleMap) { Error E = runThinLTOBackendThread( AddOutput, Task, MBRef, CombinedIndex, ImportList, ExportList, @@ -571,8 +575,8 @@ public: } }, MBRef, std::ref(CombinedIndex), std::ref(ImportList), - std::ref(ExportList), std::ref(ResolvedODR), - std::ref(ModuleToDefinedGVSummaries[ModulePath]), std::ref(ModuleMap)); + std::ref(ExportList), std::ref(ResolvedODR), std::ref(DefinedGlobals), + std::ref(ModuleMap)); return Error(); } @@ -587,7 +591,7 @@ public: ThinBackend lto::createInProcessThinBackend(unsigned ParallelismLevel) { return [=](Config &Conf, ModuleSummaryIndex &CombinedIndex, - StringMap &ModuleToDefinedGVSummaries, + const StringMap &ModuleToDefinedGVSummaries, AddOutputFn AddOutput) { return llvm::make_unique( Conf, CombinedIndex, ParallelismLevel, ModuleToDefinedGVSummaries, @@ -603,11 +607,11 @@ class WriteIndexesThinBackend : public ThinBackendProc { std::unique_ptr LinkedObjectsFile; public: - WriteIndexesThinBackend(Config &Conf, ModuleSummaryIndex &CombinedIndex, - StringMap &ModuleToDefinedGVSummaries, - std::string OldPrefix, std::string NewPrefix, - bool ShouldEmitImportsFiles, - std::string LinkedObjectsFileName) + WriteIndexesThinBackend( + Config &Conf, ModuleSummaryIndex &CombinedIndex, + const StringMap &ModuleToDefinedGVSummaries, + std::string OldPrefix, std::string NewPrefix, bool ShouldEmitImportsFiles, + std::string LinkedObjectsFileName) : ThinBackendProc(Conf, CombinedIndex, ModuleToDefinedGVSummaries), OldPrefix(OldPrefix), NewPrefix(NewPrefix), ShouldEmitImportsFiles(ShouldEmitImportsFiles), @@ -678,7 +682,7 @@ ThinBackend lto::createWriteIndexesThinBackend(std::string OldPrefix, bool ShouldEmitImportsFiles, std::string LinkedObjectsFile) { return [=](Config &Conf, ModuleSummaryIndex &CombinedIndex, - StringMap &ModuleToDefinedGVSummaries, + const StringMap &ModuleToDefinedGVSummaries, AddOutputFn AddOutput) { return llvm::make_unique( Conf, CombinedIndex, ModuleToDefinedGVSummaries, OldPrefix, NewPrefix, -- 2.7.4