@@ -865,12 +865,11 @@ static void ThreadEntryPoint(IRGenerator *irgen,
865
865
866
866
// / Generates LLVM IR, runs the LLVM passes and produces the output files.
867
867
// / All this is done in multiple threads.
868
- static void performParallelIRGeneration (IRGenOptions &Opts,
869
- swift::ModuleDecl *M,
870
- std::unique_ptr<SILModule> SILMod,
871
- const PrimarySpecificPaths &PSPs,
872
- StringRef ModuleName, int numThreads,
873
- ArrayRef<std::string> outputFilenames) {
868
+ static void performParallelIRGeneration (
869
+ IRGenOptions &Opts, swift::ModuleDecl *M, std::unique_ptr<SILModule> SILMod,
870
+ const SupplementaryOutputPaths &supplementaryOutputPathsForFirstInput,
871
+ StringRef ModuleName, int numThreads,
872
+ ArrayRef<std::string> outputFilenames) {
874
873
875
874
IRGenerator irgen (Opts, *SILMod);
876
875
@@ -903,7 +902,6 @@ static void performParallelIRGeneration(IRGenOptions &Opts,
903
902
// There must be an output filename for each source file.
904
903
// We ignore additional output filenames.
905
904
if (OutputIter == outputFilenames.end ()) {
906
- // TODO: Check this already at argument parsing.
907
905
Ctx.Diags .diagnose (SourceLoc (), diag::too_few_output_filenames);
908
906
return ;
909
907
}
@@ -916,12 +914,12 @@ static void performParallelIRGeneration(IRGenOptions &Opts,
916
914
auto Context = new LLVMContext ();
917
915
918
916
// Create the IR emitter.
919
- IRGenModule *IGM = new IRGenModule (irgen, std::move (targetMachine),
920
- nextSF, *Context,
921
- ModuleName,
922
- PrimarySpecificPaths (*OutputIter++,
923
- nextSF-> getFilename (),
924
- PSPs. SupplementaryOutputs ));
917
+ const bool isFirst = OutputIter == outputFilenames. begin ();
918
+ IRGenModule *IGM = new IRGenModule (
919
+ irgen, std::move (targetMachine), nextSF, *Context, ModuleName,
920
+ PrimarySpecificPaths (*OutputIter++, nextSF-> getFilename () ,
921
+ isFirst ? supplementaryOutputPathsForFirstInput
922
+ : SupplementaryOutputPaths () ));
925
923
IGMcreated = true ;
926
924
927
925
initLLVMModule (*IGM);
@@ -1081,17 +1079,17 @@ static void performParallelIRGeneration(IRGenOptions &Opts,
1081
1079
}
1082
1080
}
1083
1081
1084
- std::unique_ptr<llvm::Module> swift::
1085
- performIRGeneration (IRGenOptions &Opts, swift::ModuleDecl *M,
1086
- std::unique_ptr<SILModule> SILMod,
1087
- StringRef ModuleName, const PrimarySpecificPaths &PSPs,
1088
- llvm::LLVMContext &LLVMContext,
1089
- ArrayRef<std::string> parallelOutputFilenames,
1090
- llvm::GlobalVariable **outModuleHash) {
1082
+ std::unique_ptr<llvm::Module> swift::performIRGeneration (
1083
+ IRGenOptions &Opts, swift::ModuleDecl *M, std::unique_ptr<SILModule> SILMod,
1084
+ StringRef ModuleName, const PrimarySpecificPaths &PSPs,
1085
+ llvm::LLVMContext &LLVMContext,
1086
+ ArrayRef<std::string> parallelOutputFilenames,
1087
+ llvm::GlobalVariable **outModuleHash) {
1091
1088
if (SILMod->getOptions ().shouldPerformIRGenerationInParallel () &&
1092
1089
!parallelOutputFilenames.empty ()) {
1093
1090
auto NumThreads = SILMod->getOptions ().NumThreads ;
1094
- ::performParallelIRGeneration (Opts, M, std::move(SILMod), PSPs, ModuleName,
1091
+ ::performParallelIRGeneration (Opts, M, std::move(SILMod),
1092
+ PSPs.SupplementaryOutputs, ModuleName,
1095
1093
NumThreads, parallelOutputFilenames);
1096
1094
// TODO: Parallel LLVM compilation cannot be used if a (single) module is
1097
1095
// needed as return value.
0 commit comments