34
34
#include " swift/LLVMPasses/Passes.h"
35
35
#include " swift/LLVMPasses/PassesFwd.h"
36
36
#include " swift/SIL/SILModule.h"
37
+ #include " swift/SIL/SILRemarkStreamer.h"
37
38
#include " swift/SILOptimizer/PassManager/PassManager.h"
38
39
#include " swift/SILOptimizer/PassManager/PassPipeline.h"
39
40
#include " swift/SILOptimizer/PassManager/Passes.h"
@@ -884,7 +885,7 @@ static void embedBitcode(llvm::Module *M, const IRGenOptions &Opts)
884
885
NewUsed->setSection (" llvm.metadata" );
885
886
}
886
887
887
- static void initLLVMModule (const IRGenModule &IGM, ModuleDecl &M ) {
888
+ static void initLLVMModule (const IRGenModule &IGM, SILModule &SIL ) {
888
889
auto *Module = IGM.getModule ();
889
890
assert (Module && " Expected llvm:Module for IR generation!" );
890
891
@@ -902,12 +903,17 @@ static void initLLVMModule(const IRGenModule &IGM, ModuleDecl &M) {
902
903
903
904
auto *MDNode = IGM.getModule ()->getOrInsertNamedMetadata (" swift.module.flags" );
904
905
auto &Context = IGM.getModule ()->getContext ();
905
- auto *Value = M.isStdlibModule () ? llvm::ConstantInt::getTrue (Context)
906
- : llvm::ConstantInt::getFalse (Context);
906
+ auto *Value = SIL.getSwiftModule ()->isStdlibModule ()
907
+ ? llvm::ConstantInt::getTrue (Context)
908
+ : llvm::ConstantInt::getFalse (Context);
907
909
MDNode->addOperand (llvm::MDTuple::get (Context,
908
910
{llvm::MDString::get (Context,
909
911
" standard-library" ),
910
912
llvm::ConstantAsMetadata::get (Value)}));
913
+
914
+ if (auto *streamer = SIL.getSILRemarkStreamer ()) {
915
+ streamer->intoLLVMContext (Module->getContext ());
916
+ }
911
917
}
912
918
913
919
std::pair<IRGenerator *, IRGenModule *>
@@ -926,7 +932,7 @@ swift::irgen::createIRGenModule(SILModule *SILMod, StringRef OutputFilename,
926
932
*irgen, std::move (targetMachine), nullptr , " " , OutputFilename,
927
933
MainInputFilenameForDebugInfo, PrivateDiscriminator);
928
934
929
- initLLVMModule (*IGM, *SILMod-> getSwiftModule () );
935
+ initLLVMModule (*IGM, *SILMod);
930
936
931
937
return std::pair<IRGenerator *, IRGenModule *>(irgen, IGM);
932
938
}
@@ -969,7 +975,7 @@ performIRGeneration(const IRGenOptions &Opts, ModuleDecl *M,
969
975
PSPs.OutputFilename , PSPs.MainInputFilenameForDebugInfo ,
970
976
PrivateDiscriminator);
971
977
972
- initLLVMModule (IGM, *SILMod-> getSwiftModule () );
978
+ initLLVMModule (IGM, *SILMod);
973
979
974
980
// Run SIL level IRGen preparation passes.
975
981
runIRGenPreparePasses (*SILMod, IGM);
@@ -1217,7 +1223,7 @@ static void performParallelIRGeneration(
1217
1223
nextSF->getPrivateDiscriminator ().str ());
1218
1224
IGMcreated = true ;
1219
1225
1220
- initLLVMModule (*IGM, *SILMod-> getSwiftModule () );
1226
+ initLLVMModule (*IGM, *SILMod);
1221
1227
if (!DidRunSILCodeGenPreparePasses) {
1222
1228
// Run SIL level IRGen preparation passes on the module the first time
1223
1229
// around.
@@ -1431,7 +1437,7 @@ swift::createSwiftModuleObjectFile(SILModule &SILMod, StringRef Buffer,
1431
1437
1432
1438
IRGenModule IGM (irgen, std::move (targetMachine), nullptr ,
1433
1439
OutputPath, OutputPath, " " , " " );
1434
- initLLVMModule (IGM, * SILMod. getSwiftModule () );
1440
+ initLLVMModule (IGM, SILMod);
1435
1441
auto *Ty = llvm::ArrayType::get (IGM.Int8Ty , Buffer.size ());
1436
1442
auto *Data =
1437
1443
llvm::ConstantDataArray::getString (IGM.getLLVMContext (),
0 commit comments