@@ -1113,11 +1113,11 @@ struct LLVMCodeGenThreads {
1113
1113
1114
1114
// / Generates LLVM IR, runs the LLVM passes and produces the output files.
1115
1115
// / All this is done in multiple threads.
1116
- static void performParallelIRGeneration (
1117
- const IRGenOptions &Opts, swift::ModuleDecl *M, std::unique_ptr<SILModule> SILMod,
1118
- StringRef ModuleName,
1119
- ArrayRef< std::string> outputFilenames,
1120
- llvm::StringSet<> *linkerDirectives) {
1116
+ static void performParallelIRGeneration (IRGenDescriptor desc) {
1117
+ const auto &Opts = desc. Opts ;
1118
+ auto outputFilenames = desc. parallelOutputFilenames ;
1119
+ auto SILMod = std::unique_ptr<SILModule>(desc. SILMod );
1120
+ auto *M = desc. getParentModule ();
1121
1121
1122
1122
IRGenerator irgen (Opts, *SILMod);
1123
1123
@@ -1158,7 +1158,7 @@ static void performParallelIRGeneration(
1158
1158
// Create the IR emitter.
1159
1159
IRGenModule *IGM =
1160
1160
new IRGenModule (irgen, std::move (targetMachine), nextSF,
1161
- ModuleName, *OutputIter++, nextSF->getFilename (),
1161
+ desc. ModuleName , *OutputIter++, nextSF->getFilename (),
1162
1162
nextSF->getPrivateDiscriminator ().str ());
1163
1163
IGMcreated = true ;
1164
1164
@@ -1178,7 +1178,7 @@ static void performParallelIRGeneration(
1178
1178
}
1179
1179
1180
1180
// Emit the module contents.
1181
- irgen.emitGlobalTopLevel (linkerDirectives );
1181
+ irgen.emitGlobalTopLevel (desc. LinkerDirectives );
1182
1182
1183
1183
for (auto *File : M->getFiles ()) {
1184
1184
if (auto *SF = dyn_cast<SourceFile>(File)) {
@@ -1311,18 +1311,17 @@ GeneratedModule swift::performIRGeneration(
1311
1311
const PrimarySpecificPaths &PSPs,
1312
1312
ArrayRef<std::string> parallelOutputFilenames,
1313
1313
llvm::GlobalVariable **outModuleHash, llvm::StringSet<> *LinkerDirectives) {
1314
+ auto desc = IRGenDescriptor::forWholeModule (
1315
+ Opts, M, std::move (SILMod), ModuleName, PSPs, parallelOutputFilenames,
1316
+ outModuleHash, LinkerDirectives);
1317
+
1314
1318
if (Opts.shouldPerformIRGenerationInParallel () &&
1315
1319
!parallelOutputFilenames.empty ()) {
1316
- ::performParallelIRGeneration (Opts, M, std::move(SILMod), ModuleName,
1317
- parallelOutputFilenames, LinkerDirectives);
1320
+ ::performParallelIRGeneration (desc);
1318
1321
// TODO: Parallel LLVM compilation cannot be used if a (single) module is
1319
1322
// needed as return value.
1320
1323
return GeneratedModule::null ();
1321
1324
}
1322
-
1323
- auto desc = IRGenDescriptor::forWholeModule (
1324
- Opts, M, std::move (SILMod), ModuleName, PSPs, parallelOutputFilenames,
1325
- outModuleHash, LinkerDirectives);
1326
1325
return llvm::cantFail (M->getASTContext ().evaluator (IRGenRequest{desc}));
1327
1326
}
1328
1327
0 commit comments