================ @@ -613,19 +613,30 @@ static SourceLanguage MapDWLangToCVLang(unsigned DWLang) { void CodeViewDebug::beginModule(Module *M) { // If module doesn't have named metadata anchors or COFF debug section // is not available, skip any debug info related stuff. - if (!Asm->hasDebugInfo() || - !Asm->getObjFileLowering().getCOFFDebugSymbolsSection()) { + if (!Asm->getObjFileLowering().getCOFFDebugSymbolsSection()) { Asm = nullptr; return; } TheCPU = mapArchToCVCPUType(M->getTargetTriple().getArch()); // Get the current source language. - const MDNode *Node = *M->debug_compile_units_begin(); + const MDNode *Node; + if (Asm->hasDebugInfo()) { + Node = *M->debug_compile_units_begin(); + } else { + // When emitting only compiler information, we may have only NoDebug CUs, + // which would be skipped by debug_compile_units_begin. + NamedMDNode *CUs = MMI->getModule()->getNamedMetadata("llvm.dbg.cu"); + Node = *CUs->operands().begin(); + } const auto *CU = cast<DICompileUnit>(Node); CurrentSourceLanguage = MapDWLangToCVLang(CU->getSourceLanguage()); + NoDebug = ---------------- dpaoliello wrote:
Would it be possible to lift this and the early return into the `else` above? Or is there a case where `hasDebugInfo` is true, but we have NoDebug CUs? https://github.com/llvm/llvm-project/pull/142970 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits