diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2911,26 +2911,23 @@ if (UseMacro) { unsigned Type = M.getMacinfoType() == dwarf::DW_MACINFO_define - ? dwarf::DW_MACRO_define_strp - : dwarf::DW_MACRO_undef_strp; + ? dwarf::DW_MACRO_define_strx + : dwarf::DW_MACRO_undef_strx; Asm->OutStreamer->AddComment(dwarf::MacroString(Type)); Asm->emitULEB128(Type); Asm->OutStreamer->AddComment("Line Number"); Asm->emitULEB128(M.getLine()); Asm->OutStreamer->AddComment("Macro String"); if (!Value.empty()) - Asm->OutStreamer->emitSymbolValue( - this->InfoHolder.getStringPool() - .getEntry(*Asm, (Name + " " + Value).str()) - .getSymbol(), - 4); + Asm->emitULEB128(this->InfoHolder.getStringPool() + .getIndexedEntry(*Asm, (Name + " " + Value).str()) + .getIndex()); else - // DW_MACRO_undef_strp doesn't have a value, so just emit the macro + // DW_MACRO_undef_strx doesn't have a value, so just emit the macro // string. - Asm->OutStreamer->emitSymbolValue(this->InfoHolder.getStringPool() - .getEntry(*Asm, (Name).str()) - .getSymbol(), - 4); + Asm->emitULEB128(this->InfoHolder.getStringPool() + .getIndexedEntry(*Asm, (Name).str()) + .getIndex()); } else { Asm->OutStreamer->AddComment(dwarf::MacinfoString(M.getMacinfoType())); Asm->emitULEB128(M.getMacinfoType()); diff --git a/llvm/test/DebugInfo/X86/debug-macro-v5.ll b/llvm/test/DebugInfo/X86/debug-macro-v5.ll --- a/llvm/test/DebugInfo/X86/debug-macro-v5.ll +++ b/llvm/test/DebugInfo/X86/debug-macro-v5.ll @@ -11,12 +11,12 @@ ; CHECK-NEXT: macro header: version = 0x0005, flags = 0x02, debug_line_offset = 0x0000 ; CHECK-NEXT: DW_MACRO_start_file - lineno: 0 filenum: 0 ; CHECK-NEXT: DW_MACRO_start_file - lineno: 1 filenum: 1 -; CHECK-NEXT: DW_MACRO_define_strp - lineno: 1 macro: FOO 5 +; CHECK-NEXT: DW_MACRO_define_strx - lineno: 1 macro: FOO 5 ; CHECK-NEXT: DW_MACRO_end_file ; CHECK-NEXT: DW_MACRO_start_file - lineno: 2 filenum: 2 -; CHECK-NEXT: DW_MACRO_undef_strp - lineno: 14 macro: YEA +; CHECK-NEXT: DW_MACRO_undef_strx - lineno: 14 macro: YEA ; CHECK-NEXT: DW_MACRO_end_file -; CHECK-NEXT: DW_MACRO_undef_strp - lineno: 14 macro: YEA +; CHECK-NEXT: DW_MACRO_undef_strx - lineno: 14 macro: YEA ; CHECK-NEXT: DW_MACRO_end_file ; ModuleID = 'test.c'