@@ -129,8 +129,8 @@ std::string getDefaultProfileGenName() {
129
129
}
130
130
131
131
class EmitAssemblyHelper {
132
+ CompilerInstance &CI;
132
133
DiagnosticsEngine &Diags;
133
- const HeaderSearchOptions &HSOpts;
134
134
const CodeGenOptions &CodeGenOpts;
135
135
const clang::TargetOptions &TargetOpts;
136
136
const LangOptions &LangOpts;
@@ -203,15 +203,11 @@ class EmitAssemblyHelper {
203
203
}
204
204
205
205
public:
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,
211
207
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) ),
215
211
TargetTriple(TheModule->getTargetTriple ()) {}
216
212
217
213
~EmitAssemblyHelper () {
@@ -222,7 +218,7 @@ class EmitAssemblyHelper {
222
218
std::unique_ptr<TargetMachine> TM;
223
219
224
220
// 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,
226
222
BackendConsumer *BC);
227
223
};
228
224
} // namespace
@@ -351,12 +347,13 @@ static std::string flattenClangCommandLine(ArrayRef<std::string> Args,
351
347
return FlatCmdLine;
352
348
}
353
349
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 ();
360
357
switch (LangOpts.getThreadModel ()) {
361
358
case LangOptions::ThreadModelKind::POSIX:
362
359
Options.ThreadModel = llvm::ThreadModel::POSIX;
@@ -600,8 +597,7 @@ void EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) {
600
597
CodeGenOptLevel OptLevel = *OptLevelOrNone;
601
598
602
599
llvm::TargetOptions Options;
603
- if (!initTargetOptions (Diags, Options, CodeGenOpts, TargetOpts, LangOpts,
604
- HSOpts))
600
+ if (!initTargetOptions (CI, Diags, Options))
605
601
return ;
606
602
TM.reset (TheTarget->createTargetMachine (Triple, TargetOpts.CPU , FeaturesStr,
607
603
Options, RM, CM, OptLevel));
@@ -1207,7 +1203,7 @@ void EmitAssemblyHelper::RunCodegenPipeline(
1207
1203
}
1208
1204
}
1209
1205
1210
- void EmitAssemblyHelper::EmitAssembly (BackendAction Action,
1206
+ void EmitAssemblyHelper::emitAssembly (BackendAction Action,
1211
1207
std::unique_ptr<raw_pwrite_stream> OS,
1212
1208
BackendConsumer *BC) {
1213
1209
TimeRegion Region (CodeGenOpts.TimePasses ? &CodeGenerationTime : nullptr );
@@ -1234,13 +1230,14 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
1234
1230
DwoOS->keep ();
1235
1231
}
1236
1232
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 ();
1244
1241
DenseMap<StringRef, DenseMap<GlobalValue::GUID, GlobalValueSummary *>>
1245
1242
ModuleToDefinedGVSummaries;
1246
1243
CombinedIndex->collectDefinedGVSummariesPerModule (ModuleToDefinedGVSummaries);
@@ -1278,7 +1275,7 @@ static void runThinLTOBackend(
1278
1275
assert (OptLevelOrNone && " Invalid optimization level!" );
1279
1276
Conf.CGOptLevel = *OptLevelOrNone;
1280
1277
Conf.OptLevel = CGOpts.OptimizationLevel ;
1281
- initTargetOptions (Diags, Conf.Options , CGOpts, TOpts, LOpts, HeaderOpts );
1278
+ initTargetOptions (CI, Diags, Conf.Options );
1282
1279
Conf.SampleProfile = std::move (SampleProfile);
1283
1280
Conf.PTO .LoopUnrolling = CGOpts.UnrollLoops ;
1284
1281
// For historical reasons, loop interleaving is set to mirror setting for loop
@@ -1341,14 +1338,14 @@ static void runThinLTOBackend(
1341
1338
}
1342
1339
}
1343
1340
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) {
1351
1346
llvm::TimeTraceScope TimeScope (" Backend" );
1347
+ DiagnosticsEngine &Diags = CI.getDiagnostics ();
1348
+ const auto &CGOpts = CI.getCodeGenOpts ();
1352
1349
1353
1350
std::unique_ptr<llvm::Module> EmptyModule;
1354
1351
if (!CGOpts.ThinLTOIndexFile .empty ()) {
@@ -1371,9 +1368,9 @@ void clang::EmitBackendOutput(
1371
1368
// of an error).
1372
1369
if (CombinedIndex) {
1373
1370
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);
1377
1374
return ;
1378
1375
}
1379
1376
// Distributed indexing detected that nothing from the module is needed
@@ -1388,8 +1385,8 @@ void clang::EmitBackendOutput(
1388
1385
}
1389
1386
}
1390
1387
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);
1393
1390
1394
1391
// Verify clang's TargetInfo DataLayout against the LLVM TargetMachine's
1395
1392
// DataLayout.
0 commit comments