[clang] [llvm] [CodeGen][COFF] Always emit CodeView compiler info on Windows targets (PR #142970)
Daniel Paoliello via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 6 10:06:06 PDT 2025
================
@@ -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
More information about the llvm-commits
mailing list