@@ -625,13 +625,15 @@ void CodeViewDebug::beginModule(Module *M) {
625625 if (Asm->hasDebugInfo ()) {
626626 Node = *M->debug_compile_units_begin ();
627627 } else {
628- auto DebugCompileUnits = MMI->getModule ()->debug_compile_units ();
629- if (DebugCompileUnits.empty ())
630- return ;
631-
632628 // When emitting only compiler information, we may have only NoDebug CUs,
633629 // which would be skipped by debug_compile_units_begin.
634- Node = *DebugCompileUnits.begin ();
630+ NamedMDNode *CUs = MMI->getModule ()->getNamedMetadata (" llvm.dbg.cu" );
631+ if (CUs->operands ().empty ()) {
632+ Asm = nullptr ;
633+ return ;
634+ }
635+
636+ Node = *CUs->operands ().begin ();
635637 }
636638 const auto *CU = cast<DICompileUnit>(Node);
637639 DISourceLanguageName Lang = CU->getSourceLanguage ();
@@ -903,18 +905,19 @@ void CodeViewDebug::emitCompilerInformation() {
903905 OS.AddComment (" CPUType" );
904906 OS.emitInt16 (static_cast <uint64_t >(TheCPU));
905907
908+ NamedMDNode *CUs = MMI->getModule ()->getNamedMetadata (" llvm.dbg.cu" );
909+
906910 StringRef CompilerVersion = " 0" ;
907- auto CUs = MMI->getModule ()->debug_compile_units ();
908- if (!CUs.empty ()) {
909- const MDNode *Node = *CUs.begin ();
911+ if (!CUs->operands ().empty ()) {
912+ const MDNode *Node = *CUs->operands ().begin ();
910913 const auto *CU = cast<DICompileUnit>(Node);
911-
912914 CompilerVersion = CU->getProducer ();
913- Version FrontVer = parseVersion (CompilerVersion);
914- OS.AddComment (" Frontend version" );
915- for (int N : FrontVer.Part ) {
916- OS.emitInt16 (N);
917- }
915+ }
916+
917+ Version FrontVer = parseVersion (CompilerVersion);
918+ OS.AddComment (" Frontend version" );
919+ for (int N : FrontVer.Part ) {
920+ OS.emitInt16 (N);
918921 }
919922
920923 // Some Microsoft tools, like Binscope, expect a backend version number of at
@@ -954,11 +957,8 @@ void CodeViewDebug::emitBuildInfo() {
954957 // not clear if the compiler path should refer to the executable for the
955958 // frontend or the backend. Leave it blank for now.
956959 TypeIndex BuildInfoArgs[BuildInfoRecord::MaxArgs] = {};
957- auto CUs = MMI->getModule ()->debug_compile_units ();
958- if (CUs.empty ())
959- return ;
960-
961- const MDNode *Node = *CUs.begin (); // FIXME: Multiple CUs.
960+ NamedMDNode *CUs = MMI->getModule ()->getNamedMetadata (" llvm.dbg.cu" );
961+ const MDNode *Node = *CUs->operands ().begin (); // FIXME: Multiple CUs.
962962 const auto *CU = cast<DICompileUnit>(Node);
963963 const DIFile *MainSourceFile = CU->getFile ();
964964 BuildInfoArgs[BuildInfoRecord::CurrentDirectory] =
0 commit comments