diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -228,8 +228,11 @@ continue; // Nothing to describe without address or constant. + // In LLD Global is nullptr and Expr->Elements=={}. +#if 0 // It breaks llvm/test/DebugInfo/X86/unattached-global.ll if (!Global && (!Expr || !Expr->isConstant())) continue; +#endif if (Global && Global->isThreadLocal() && !Asm->getObjFileLowering().supportDebugThreadLocalLocation()) diff --git a/llvm/test/DebugInfo/Generic/debug-names-namespace-lto.test b/llvm/test/DebugInfo/Generic/debug-names-namespace-lto.test new file mode 100644 --- /dev/null +++ b/llvm/test/DebugInfo/Generic/debug-names-namespace-lto.test @@ -0,0 +1,8 @@ +RUN: echo 'namespace N { int varname; } extern "C" void _start(){}' | clang++ -Wall -Werror -gdwarf-5 -gpubnames -fuse-ld=lld -nostdlib -o %t -flto -x c++ - +RUN: llvm-dwarfdump -debug-names %t | FileCheck %s + +CHECK: String: 0x{{[0-9a-f]*}} "varname" +CHECK-NEXT: Entry +CHECK-NEXT: Abbrev: +CHECK-NEXT: Tag: DW_TAG_variable +CHECK-NEXT: DW_IDX_die_offset: 0x{{[0-9a-f]*}}