aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/LTO/LTO.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2020-01-13 12:23:34 -0800
committerTeresa Johnson <tejohnson@google.com>2020-01-13 12:26:17 -0800
commitd0aad9f56e1588effa94b15804b098e6307da6b4 (patch)
tree9581de88c751dcf2ae45fd5b3ab9b4472aeaa35b /llvm/lib/LTO/LTO.cpp
parenta0f4600f4f0ece1d4779544513f5a70c6f0d78bf (diff)
downloadllvm-d0aad9f56e1588effa94b15804b098e6307da6b4.zip
llvm-d0aad9f56e1588effa94b15804b098e6307da6b4.tar.gz
llvm-d0aad9f56e1588effa94b15804b098e6307da6b4.tar.bz2
[LTO] Constify lto::Config reference passed to backends (NFC)
The lto::Config object saved on the global LTO object should not be updated by any of the LTO backends. Otherwise we could run into interference between threads utilizing it. Motivated by some proposed changes that would have caused it to get modified in the ThinLTO backends.
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r--llvm/lib/LTO/LTO.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 950315f..297b11d 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -467,7 +467,7 @@ BitcodeModule &InputFile::getSingleBitcodeModule() {
}
LTO::RegularLTOState::RegularLTOState(unsigned ParallelCodeGenParallelismLevel,
- Config &Conf)
+ const Config &Conf)
: ParallelCodeGenParallelismLevel(ParallelCodeGenParallelismLevel),
Ctx(Conf), CombinedModule(std::make_unique<Module>("ld-temp.o", Ctx)),
Mover(std::make_unique<IRMover>(*CombinedModule)) {}
@@ -1029,12 +1029,12 @@ ArrayRef<const char*> LTO::getRuntimeLibcallSymbols() {
/// This class defines the interface to the ThinLTO backend.
class lto::ThinBackendProc {
protected:
- Config &Conf;
+ const Config &Conf;
ModuleSummaryIndex &CombinedIndex;
const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries;
public:
- ThinBackendProc(Config &Conf, ModuleSummaryIndex &CombinedIndex,
+ ThinBackendProc(const Config &Conf, ModuleSummaryIndex &CombinedIndex,
const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries)
: Conf(Conf), CombinedIndex(CombinedIndex),
ModuleToDefinedGVSummaries(ModuleToDefinedGVSummaries) {}
@@ -1062,7 +1062,7 @@ class InProcessThinBackend : public ThinBackendProc {
public:
InProcessThinBackend(
- Config &Conf, ModuleSummaryIndex &CombinedIndex,
+ const Config &Conf, ModuleSummaryIndex &CombinedIndex,
unsigned ThinLTOParallelismLevel,
const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
AddStreamFn AddStream, NativeObjectCache Cache)
@@ -1160,7 +1160,7 @@ public:
} // end anonymous namespace
ThinBackend lto::createInProcessThinBackend(unsigned ParallelismLevel) {
- return [=](Config &Conf, ModuleSummaryIndex &CombinedIndex,
+ return [=](const Config &Conf, ModuleSummaryIndex &CombinedIndex,
const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
AddStreamFn AddStream, NativeObjectCache Cache) {
return std::make_unique<InProcessThinBackend>(
@@ -1198,7 +1198,7 @@ class WriteIndexesThinBackend : public ThinBackendProc {
public:
WriteIndexesThinBackend(
- Config &Conf, ModuleSummaryIndex &CombinedIndex,
+ const Config &Conf, ModuleSummaryIndex &CombinedIndex,
const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
std::string OldPrefix, std::string NewPrefix, bool ShouldEmitImportsFiles,
raw_fd_ostream *LinkedObjectsFile, lto::IndexWriteCallback OnWrite)
@@ -1250,7 +1250,7 @@ public:
ThinBackend lto::createWriteIndexesThinBackend(
std::string OldPrefix, std::string NewPrefix, bool ShouldEmitImportsFiles,
raw_fd_ostream *LinkedObjectsFile, IndexWriteCallback OnWrite) {
- return [=](Config &Conf, ModuleSummaryIndex &CombinedIndex,
+ return [=](const Config &Conf, ModuleSummaryIndex &CombinedIndex,
const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
AddStreamFn AddStream, NativeObjectCache Cache) {
return std::make_unique<WriteIndexesThinBackend>(