@@ -189,7 +189,7 @@ void swift::performLLVMOptimizations(IRGenOptions &Opts, llvm::Module *Module,
189
189
PMBuilder.addExtension (PassManagerBuilder::EP_EnabledOnOptLevel0,
190
190
addAddressSanitizerPasses);
191
191
}
192
-
192
+
193
193
if (Opts.Sanitizers & SanitizerKind::Thread) {
194
194
PMBuilder.addExtension (PassManagerBuilder::EP_OptimizerLast,
195
195
addThreadSanitizerPass);
@@ -657,7 +657,7 @@ static void embedBitcode(llvm::Module *M, const IRGenOptions &Opts)
657
657
static void initLLVMModule (const IRGenModule &IGM) {
658
658
auto *Module = IGM.getModule ();
659
659
assert (Module && " Expected llvm:Module for IR generation!" );
660
-
660
+
661
661
Module->setTargetTriple (IGM.Triple .str ());
662
662
663
663
// Set the module's string representation.
@@ -736,7 +736,7 @@ static std::unique_ptr<llvm::Module> performIRGeneration(IRGenOptions &Opts,
736
736
737
737
// Run SIL level IRGen preparation passes.
738
738
runIRGenPreparePasses (*SILMod, IGM);
739
-
739
+
740
740
{
741
741
SharedTimer timer (" IRGen" );
742
742
// Emit the module contents.
@@ -884,7 +884,7 @@ static void performParallelIRGeneration(IRGenOptions &Opts,
884
884
}
885
885
}
886
886
} _igmDeleter (irgen);
887
-
887
+
888
888
auto OutputIter = Opts.OutputFilenames .begin ();
889
889
bool IGMcreated = false ;
890
890
@@ -895,7 +895,7 @@ static void performParallelIRGeneration(IRGenOptions &Opts,
895
895
auto nextSF = dyn_cast<SourceFile>(File);
896
896
if (!nextSF || nextSF->ASTStage < SourceFile::TypeChecked)
897
897
continue ;
898
-
898
+
899
899
// There must be an output filename for each source file.
900
900
// We ignore additional output filenames.
901
901
if (OutputIter == Opts.OutputFilenames .end ()) {
@@ -908,9 +908,9 @@ static void performParallelIRGeneration(IRGenOptions &Opts,
908
908
if (!targetMachine) continue ;
909
909
910
910
// This (and the IGM itself) will get deleted by the IGMDeleter
911
- // as long as the IGM is registered with the IRGenerator.
911
+ // as long as the IGM is registered with the IRGenerator.
912
912
auto Context = new LLVMContext ();
913
-
913
+
914
914
// Create the IR emitter.
915
915
IRGenModule *IGM = new IRGenModule (irgen, std::move (targetMachine),
916
916
nextSF, *Context,
@@ -925,7 +925,7 @@ static void performParallelIRGeneration(IRGenOptions &Opts,
925
925
DidRunSILCodeGenPreparePasses = true ;
926
926
}
927
927
}
928
-
928
+
929
929
if (!IGMcreated) {
930
930
// TODO: Check this already at argument parsing.
931
931
Ctx.Diags .diagnose (SourceLoc (), diag::no_input_files_for_mt);
@@ -934,7 +934,7 @@ static void performParallelIRGeneration(IRGenOptions &Opts,
934
934
935
935
// Emit the module contents.
936
936
irgen.emitGlobalTopLevel ();
937
-
937
+
938
938
for (auto *File : M->getFiles ()) {
939
939
if (auto *SF = dyn_cast<SourceFile>(File)) {
940
940
IRGenModule *IGM = irgen.getGenModule (SF);
@@ -945,7 +945,7 @@ static void performParallelIRGeneration(IRGenOptions &Opts,
945
945
});
946
946
}
947
947
}
948
-
948
+
949
949
// Okay, emit any definitions that we suddenly need.
950
950
irgen.emitLazyDefinitions ();
951
951
@@ -966,32 +966,32 @@ static void performParallelIRGeneration(IRGenOptions &Opts,
966
966
967
967
// Emit symbols for eliminated dead methods.
968
968
PrimaryGM->emitVTableStubs ();
969
-
969
+
970
970
// Verify type layout if we were asked to.
971
971
if (!Opts.VerifyTypeLayoutNames .empty ())
972
972
PrimaryGM->emitTypeVerifier ();
973
-
973
+
974
974
std::for_each (Opts.LinkLibraries .begin (), Opts.LinkLibraries .end (),
975
975
[&](LinkLibrary linkLib) {
976
976
PrimaryGM->addLinkLibrary (linkLib);
977
977
});
978
-
978
+
979
979
// Hack to handle thunks eagerly synthesized by the Clang importer.
980
980
swift::ModuleDecl *prev = nullptr ;
981
981
for (auto external : Ctx.ExternalDefinitions ) {
982
982
swift::ModuleDecl *next = external->getModuleContext ();
983
983
if (next == prev)
984
984
continue ;
985
985
prev = next;
986
-
986
+
987
987
if (next->getName () == M->getName ())
988
988
continue ;
989
-
989
+
990
990
next->collectLinkLibraries ([&](LinkLibrary linkLib) {
991
991
PrimaryGM->addLinkLibrary (linkLib);
992
992
});
993
993
}
994
-
994
+
995
995
llvm::StringSet<> referencedGlobals;
996
996
997
997
for (auto it = irgen.begin (); it != irgen.end (); ++it) {
@@ -1019,7 +1019,7 @@ static void performParallelIRGeneration(IRGenOptions &Opts,
1019
1019
for (auto it = irgen.begin (); it != irgen.end (); ++it) {
1020
1020
IRGenModule *IGM = it->second ;
1021
1021
llvm::Module *M = IGM->getModule ();
1022
-
1022
+
1023
1023
// Update the linkage of shared functions/globals.
1024
1024
// If a shared function/global is referenced from another file it must have
1025
1025
// weak instead of linkonce linkage. Otherwise LLVM would remove the
0 commit comments