diff options
author | Teresa Johnson <tejohnson@google.com> | 2020-01-13 12:23:34 -0800 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2020-01-13 12:26:17 -0800 |
commit | d0aad9f56e1588effa94b15804b098e6307da6b4 (patch) | |
tree | 9581de88c751dcf2ae45fd5b3ab9b4472aeaa35b /llvm/lib/LTO/LTOBackend.cpp | |
parent | a0f4600f4f0ece1d4779544513f5a70c6f0d78bf (diff) | |
download | llvm-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/LTOBackend.cpp')
-rw-r--r-- | llvm/lib/LTO/LTOBackend.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index ef40d24..dcde727 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -128,7 +128,7 @@ Error Config::addSaveTemps(std::string OutputFileName, namespace { std::unique_ptr<TargetMachine> -createTargetMachine(Config &Conf, const Target *TheTarget, Module &M) { +createTargetMachine(const Config &Conf, const Target *TheTarget, Module &M) { StringRef TheTriple = M.getTargetTriple(); SubtargetFeatures Features; Features.getDefaultSubtargetFeatures(Triple(TheTriple)); @@ -153,7 +153,7 @@ createTargetMachine(Config &Conf, const Target *TheTarget, Module &M) { CodeModel, Conf.CGOptLevel)); } -static void runNewPMPasses(Config &Conf, Module &Mod, TargetMachine *TM, +static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM, unsigned OptLevel, bool IsThinLTO, ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary) { @@ -269,7 +269,7 @@ static void runNewPMCustomPasses(Module &Mod, TargetMachine *TM, MPM.run(Mod, MAM); } -static void runOldPMPasses(Config &Conf, Module &Mod, TargetMachine *TM, +static void runOldPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM, bool IsThinLTO, ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary) { legacy::PassManager passes; @@ -300,7 +300,7 @@ static void runOldPMPasses(Config &Conf, Module &Mod, TargetMachine *TM, passes.run(Mod); } -bool opt(Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod, +bool opt(const Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod, bool IsThinLTO, ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary) { // FIXME: Plumb the combined index into the new pass manager. @@ -319,7 +319,7 @@ static cl::opt<bool> EmbedBitcode( "lto-embed-bitcode", cl::init(false), cl::desc("Embed LLVM bitcode in object files produced by LTO")); -static void EmitBitcodeSection(Module &M, Config &Conf) { +static void EmitBitcodeSection(Module &M, const Config &Conf) { if (!EmbedBitcode) return; SmallVector<char, 0> Buffer; @@ -332,7 +332,7 @@ static void EmitBitcodeSection(Module &M, Config &Conf) { /*EmbedMarker*/ false, /*CmdArgs*/ nullptr); } -void codegen(Config &Conf, TargetMachine *TM, AddStreamFn AddStream, +void codegen(const Config &Conf, TargetMachine *TM, AddStreamFn AddStream, unsigned Task, Module &Mod) { if (Conf.PreCodeGenModuleHook && !Conf.PreCodeGenModuleHook(Task, Mod)) return; @@ -372,7 +372,7 @@ void codegen(Config &Conf, TargetMachine *TM, AddStreamFn AddStream, DwoOut->keep(); } -void splitCodeGen(Config &C, TargetMachine *TM, AddStreamFn AddStream, +void splitCodeGen(const Config &C, TargetMachine *TM, AddStreamFn AddStream, unsigned ParallelCodeGenParallelismLevel, std::unique_ptr<Module> Mod) { ThreadPool CodegenThreadPool(ParallelCodeGenParallelismLevel); @@ -420,7 +420,7 @@ void splitCodeGen(Config &C, TargetMachine *TM, AddStreamFn AddStream, CodegenThreadPool.wait(); } -Expected<const Target *> initAndLookupTarget(Config &C, Module &Mod) { +Expected<const Target *> initAndLookupTarget(const Config &C, Module &Mod) { if (!C.OverrideTriple.empty()) Mod.setTargetTriple(C.OverrideTriple); else if (Mod.getTargetTriple().empty()) @@ -432,7 +432,6 @@ Expected<const Target *> initAndLookupTarget(Config &C, Module &Mod) { return make_error<StringError>(Msg, inconvertibleErrorCode()); return T; } - } static Error @@ -446,7 +445,7 @@ finalizeOptimizationRemarks(std::unique_ptr<ToolOutputFile> DiagOutputFile) { return Error::success(); } -Error lto::backend(Config &C, AddStreamFn AddStream, +Error lto::backend(const Config &C, AddStreamFn AddStream, unsigned ParallelCodeGenParallelismLevel, std::unique_ptr<Module> Mod, ModuleSummaryIndex &CombinedIndex) { @@ -500,7 +499,7 @@ static void dropDeadSymbols(Module &Mod, const GVSummaryMapTy &DefinedGlobals, } } -Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream, +Error lto::thinBackend(const Config &Conf, unsigned Task, AddStreamFn AddStream, Module &Mod, const ModuleSummaryIndex &CombinedIndex, const FunctionImporter::ImportMapTy &ImportList, const GVSummaryMapTy &DefinedGlobals, |