3434#include " swift/LLVMPasses/Passes.h"
3535#include " swift/LLVMPasses/PassesFwd.h"
3636#include " swift/SIL/SILModule.h"
37+ #include " swift/SIL/SILRemarkStreamer.h"
3738#include " swift/SILOptimizer/PassManager/PassManager.h"
3839#include " swift/SILOptimizer/PassManager/PassPipeline.h"
3940#include " swift/SILOptimizer/PassManager/Passes.h"
@@ -884,7 +885,7 @@ static void embedBitcode(llvm::Module *M, const IRGenOptions &Opts)
884885 NewUsed->setSection (" llvm.metadata" );
885886}
886887
887- static void initLLVMModule (const IRGenModule &IGM, ModuleDecl &M ) {
888+ static void initLLVMModule (const IRGenModule &IGM, SILModule &SIL ) {
888889 auto *Module = IGM.getModule ();
889890 assert (Module && " Expected llvm:Module for IR generation!" );
890891
@@ -902,12 +903,17 @@ static void initLLVMModule(const IRGenModule &IGM, ModuleDecl &M) {
902903
903904 auto *MDNode = IGM.getModule ()->getOrInsertNamedMetadata (" swift.module.flags" );
904905 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);
907909 MDNode->addOperand (llvm::MDTuple::get (Context,
908910 {llvm::MDString::get (Context,
909911 " standard-library" ),
910912 llvm::ConstantAsMetadata::get (Value)}));
913+
914+ if (auto *streamer = SIL.getSILRemarkStreamer ()) {
915+ streamer->intoLLVMContext (Module->getContext ());
916+ }
911917}
912918
913919std::pair<IRGenerator *, IRGenModule *>
@@ -926,7 +932,7 @@ swift::irgen::createIRGenModule(SILModule *SILMod, StringRef OutputFilename,
926932 *irgen, std::move (targetMachine), nullptr , " " , OutputFilename,
927933 MainInputFilenameForDebugInfo, PrivateDiscriminator);
928934
929- initLLVMModule (*IGM, *SILMod-> getSwiftModule () );
935+ initLLVMModule (*IGM, *SILMod);
930936
931937 return std::pair<IRGenerator *, IRGenModule *>(irgen, IGM);
932938}
@@ -969,7 +975,7 @@ performIRGeneration(const IRGenOptions &Opts, ModuleDecl *M,
969975 PSPs.OutputFilename , PSPs.MainInputFilenameForDebugInfo ,
970976 PrivateDiscriminator);
971977
972- initLLVMModule (IGM, *SILMod-> getSwiftModule () );
978+ initLLVMModule (IGM, *SILMod);
973979
974980 // Run SIL level IRGen preparation passes.
975981 runIRGenPreparePasses (*SILMod, IGM);
@@ -1217,7 +1223,7 @@ static void performParallelIRGeneration(
12171223 nextSF->getPrivateDiscriminator ().str ());
12181224 IGMcreated = true ;
12191225
1220- initLLVMModule (*IGM, *SILMod-> getSwiftModule () );
1226+ initLLVMModule (*IGM, *SILMod);
12211227 if (!DidRunSILCodeGenPreparePasses) {
12221228 // Run SIL level IRGen preparation passes on the module the first time
12231229 // around.
@@ -1431,7 +1437,7 @@ swift::createSwiftModuleObjectFile(SILModule &SILMod, StringRef Buffer,
14311437
14321438 IRGenModule IGM (irgen, std::move (targetMachine), nullptr ,
14331439 OutputPath, OutputPath, " " , " " );
1434- initLLVMModule (IGM, * SILMod. getSwiftModule () );
1440+ initLLVMModule (IGM, SILMod);
14351441 auto *Ty = llvm::ArrayType::get (IGM.Int8Ty , Buffer.size ());
14361442 auto *Data =
14371443 llvm::ConstantDataArray::getString (IGM.getLLVMContext (),
0 commit comments