@@ -129,8 +129,8 @@ std::string getDefaultProfileGenName() {
129129}
130130
131131class EmitAssemblyHelper {
132+ CompilerInstance &CI;
132133 DiagnosticsEngine &Diags;
133- const HeaderSearchOptions &HSOpts;
134134 const CodeGenOptions &CodeGenOpts;
135135 const clang::TargetOptions &TargetOpts;
136136 const LangOptions &LangOpts;
@@ -203,15 +203,11 @@ class EmitAssemblyHelper {
203203 }
204204
205205public:
206- EmitAssemblyHelper (DiagnosticsEngine &_Diags,
207- const HeaderSearchOptions &HeaderSearchOpts,
208- const CodeGenOptions &CGOpts,
209- const clang::TargetOptions &TOpts,
210- const LangOptions &LOpts, llvm::Module *M,
206+ EmitAssemblyHelper (CompilerInstance &CI, llvm::Module *M,
211207 IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS)
212- : Diags(_Diags ), HSOpts(HeaderSearchOpts) , CodeGenOpts(CGOpts ),
213- TargetOpts (TOpts), LangOpts(LOpts), TheModule(M ), VFS(std::move(VFS )),
214- CodeGenerationTime( " codegen " , " Code Generation Time " ),
208+ : CI(CI ), Diags(CI.getDiagnostics()) , CodeGenOpts(CI.getCodeGenOpts() ),
209+ TargetOpts (CI.getTargetOpts() ), LangOpts(CI.getLangOpts( )),
210+ TheModule(M), VFS(std::move(VFS) ),
215211 TargetTriple(TheModule->getTargetTriple ()) {}
216212
217213 ~EmitAssemblyHelper () {
@@ -222,7 +218,7 @@ class EmitAssemblyHelper {
222218 std::unique_ptr<TargetMachine> TM;
223219
224220 // Emit output using the new pass manager for the optimization pipeline.
225- void EmitAssembly (BackendAction Action, std::unique_ptr<raw_pwrite_stream> OS,
221+ void emitAssembly (BackendAction Action, std::unique_ptr<raw_pwrite_stream> OS,
226222 BackendConsumer *BC);
227223};
228224} // namespace
@@ -351,12 +347,13 @@ static std::string flattenClangCommandLine(ArrayRef<std::string> Args,
351347 return FlatCmdLine;
352348}
353349
354- static bool initTargetOptions (DiagnosticsEngine &Diags,
355- llvm::TargetOptions &Options,
356- const CodeGenOptions &CodeGenOpts,
357- const clang::TargetOptions &TargetOpts,
358- const LangOptions &LangOpts,
359- const HeaderSearchOptions &HSOpts) {
350+ static bool initTargetOptions (const CompilerInstance &CI,
351+ DiagnosticsEngine &Diags,
352+ llvm::TargetOptions &Options) {
353+ const auto &CodeGenOpts = CI.getCodeGenOpts ();
354+ const auto &TargetOpts = CI.getTargetOpts ();
355+ const auto &LangOpts = CI.getLangOpts ();
356+ const auto &HSOpts = CI.getHeaderSearchOpts ();
360357 switch (LangOpts.getThreadModel ()) {
361358 case LangOptions::ThreadModelKind::POSIX:
362359 Options.ThreadModel = llvm::ThreadModel::POSIX;
@@ -600,8 +597,7 @@ void EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) {
600597 CodeGenOptLevel OptLevel = *OptLevelOrNone;
601598
602599 llvm::TargetOptions Options;
603- if (!initTargetOptions (Diags, Options, CodeGenOpts, TargetOpts, LangOpts,
604- HSOpts))
600+ if (!initTargetOptions (CI, Diags, Options))
605601 return ;
606602 TM.reset (TheTarget->createTargetMachine (Triple, TargetOpts.CPU , FeaturesStr,
607603 Options, RM, CM, OptLevel));
@@ -1207,7 +1203,7 @@ void EmitAssemblyHelper::RunCodegenPipeline(
12071203 }
12081204}
12091205
1210- void EmitAssemblyHelper::EmitAssembly (BackendAction Action,
1206+ void EmitAssemblyHelper::emitAssembly (BackendAction Action,
12111207 std::unique_ptr<raw_pwrite_stream> OS,
12121208 BackendConsumer *BC) {
12131209 TimeRegion Region (CodeGenOpts.TimePasses ? &CodeGenerationTime : nullptr );
@@ -1234,13 +1230,14 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
12341230 DwoOS->keep ();
12351231}
12361232
1237- static void runThinLTOBackend (
1238- DiagnosticsEngine &Diags, ModuleSummaryIndex *CombinedIndex,
1239- llvm::Module *M, const HeaderSearchOptions &HeaderOpts,
1240- const CodeGenOptions &CGOpts, const clang::TargetOptions &TOpts,
1241- const LangOptions &LOpts, std::unique_ptr<raw_pwrite_stream> OS,
1242- std::string SampleProfile, std::string ProfileRemapping,
1243- BackendAction Action) {
1233+ static void
1234+ runThinLTOBackend (CompilerInstance &CI, ModuleSummaryIndex *CombinedIndex,
1235+ llvm::Module *M, std::unique_ptr<raw_pwrite_stream> OS,
1236+ std::string SampleProfile, std::string ProfileRemapping,
1237+ BackendAction Action) {
1238+ DiagnosticsEngine &Diags = CI.getDiagnostics ();
1239+ const auto &CGOpts = CI.getCodeGenOpts ();
1240+ const auto &TOpts = CI.getTargetOpts ();
12441241 DenseMap<StringRef, DenseMap<GlobalValue::GUID, GlobalValueSummary *>>
12451242 ModuleToDefinedGVSummaries;
12461243 CombinedIndex->collectDefinedGVSummariesPerModule (ModuleToDefinedGVSummaries);
@@ -1278,7 +1275,7 @@ static void runThinLTOBackend(
12781275 assert (OptLevelOrNone && " Invalid optimization level!" );
12791276 Conf.CGOptLevel = *OptLevelOrNone;
12801277 Conf.OptLevel = CGOpts.OptimizationLevel ;
1281- initTargetOptions (Diags, Conf.Options , CGOpts, TOpts, LOpts, HeaderOpts );
1278+ initTargetOptions (CI, Diags, Conf.Options );
12821279 Conf.SampleProfile = std::move (SampleProfile);
12831280 Conf.PTO .LoopUnrolling = CGOpts.UnrollLoops ;
12841281 // For historical reasons, loop interleaving is set to mirror setting for loop
@@ -1341,14 +1338,14 @@ static void runThinLTOBackend(
13411338 }
13421339}
13431340
1344- void clang::EmitBackendOutput (
1345- DiagnosticsEngine &Diags, const HeaderSearchOptions &HeaderOpts,
1346- const CodeGenOptions &CGOpts, const clang::TargetOptions &TOpts,
1347- const LangOptions &LOpts, StringRef TDesc, llvm::Module *M,
1348- BackendAction Action, IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
1349- std::unique_ptr<raw_pwrite_stream> OS, BackendConsumer *BC) {
1350-
1341+ void clang::emitBackendOutput (CompilerInstance &CI, StringRef TDesc,
1342+ llvm::Module *M, BackendAction Action,
1343+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
1344+ std::unique_ptr<raw_pwrite_stream> OS,
1345+ BackendConsumer *BC) {
13511346 llvm::TimeTraceScope TimeScope (" Backend" );
1347+ DiagnosticsEngine &Diags = CI.getDiagnostics ();
1348+ const auto &CGOpts = CI.getCodeGenOpts ();
13521349
13531350 std::unique_ptr<llvm::Module> EmptyModule;
13541351 if (!CGOpts.ThinLTOIndexFile .empty ()) {
@@ -1371,9 +1368,9 @@ void clang::EmitBackendOutput(
13711368 // of an error).
13721369 if (CombinedIndex) {
13731370 if (!CombinedIndex->skipModuleByDistributedBackend ()) {
1374- runThinLTOBackend (Diags , CombinedIndex.get (), M, HeaderOpts, CGOpts ,
1375- TOpts, LOpts, std::move (OS), CGOpts.SampleProfileFile ,
1376- CGOpts. ProfileRemappingFile , Action);
1371+ runThinLTOBackend (CI , CombinedIndex.get (), M, std::move (OS) ,
1372+ CGOpts. SampleProfileFile , CGOpts.ProfileRemappingFile ,
1373+ Action);
13771374 return ;
13781375 }
13791376 // Distributed indexing detected that nothing from the module is needed
@@ -1388,8 +1385,8 @@ void clang::EmitBackendOutput(
13881385 }
13891386 }
13901387
1391- EmitAssemblyHelper AsmHelper (Diags, HeaderOpts, CGOpts, TOpts, LOpts , M, VFS);
1392- AsmHelper.EmitAssembly (Action, std::move (OS), BC);
1388+ EmitAssemblyHelper AsmHelper (CI , M, VFS);
1389+ AsmHelper.emitAssembly (Action, std::move (OS), BC);
13931390
13941391 // Verify clang's TargetInfo DataLayout against the LLVM TargetMachine's
13951392 // DataLayout.
0 commit comments