Skip to content

Commit 24dc744

Browse files
committed
Have performParallelIRGeneration take an IRGenDescriptor
1 parent b5f9e05 commit 24dc744

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

lib/IRGen/IRGen.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,11 +1113,11 @@ struct LLVMCodeGenThreads {
11131113

11141114
/// Generates LLVM IR, runs the LLVM passes and produces the output files.
11151115
/// 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();
11211121

11221122
IRGenerator irgen(Opts, *SILMod);
11231123

@@ -1158,7 +1158,7 @@ static void performParallelIRGeneration(
11581158
// Create the IR emitter.
11591159
IRGenModule *IGM =
11601160
new IRGenModule(irgen, std::move(targetMachine), nextSF,
1161-
ModuleName, *OutputIter++, nextSF->getFilename(),
1161+
desc.ModuleName, *OutputIter++, nextSF->getFilename(),
11621162
nextSF->getPrivateDiscriminator().str());
11631163
IGMcreated = true;
11641164

@@ -1178,7 +1178,7 @@ static void performParallelIRGeneration(
11781178
}
11791179

11801180
// Emit the module contents.
1181-
irgen.emitGlobalTopLevel(linkerDirectives);
1181+
irgen.emitGlobalTopLevel(desc.LinkerDirectives);
11821182

11831183
for (auto *File : M->getFiles()) {
11841184
if (auto *SF = dyn_cast<SourceFile>(File)) {
@@ -1311,18 +1311,17 @@ GeneratedModule swift::performIRGeneration(
13111311
const PrimarySpecificPaths &PSPs,
13121312
ArrayRef<std::string> parallelOutputFilenames,
13131313
llvm::GlobalVariable **outModuleHash, llvm::StringSet<> *LinkerDirectives) {
1314+
auto desc = IRGenDescriptor::forWholeModule(
1315+
Opts, M, std::move(SILMod), ModuleName, PSPs, parallelOutputFilenames,
1316+
outModuleHash, LinkerDirectives);
1317+
13141318
if (Opts.shouldPerformIRGenerationInParallel() &&
13151319
!parallelOutputFilenames.empty()) {
1316-
::performParallelIRGeneration(Opts, M, std::move(SILMod), ModuleName,
1317-
parallelOutputFilenames, LinkerDirectives);
1320+
::performParallelIRGeneration(desc);
13181321
// TODO: Parallel LLVM compilation cannot be used if a (single) module is
13191322
// needed as return value.
13201323
return GeneratedModule::null();
13211324
}
1322-
1323-
auto desc = IRGenDescriptor::forWholeModule(
1324-
Opts, M, std::move(SILMod), ModuleName, PSPs, parallelOutputFilenames,
1325-
outModuleHash, LinkerDirectives);
13261325
return llvm::cantFail(M->getASTContext().evaluator(IRGenRequest{desc}));
13271326
}
13281327

0 commit comments

Comments
 (0)