<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 7, 2016 at 6:28 AM, Amjad Aboud via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: aaboud<br>
Date: Thu Jan 7 08:28:20 2016<br>
New Revision: 257060<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=257060&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=257060&view=rev</a><br>
Log:<br>
Added support for macro emission in dwarf (supporting DWARF version 4).<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D15495" rel="noreferrer" target="_blank">http://reviews.llvm.org/D15495</a><br>
<br>
Added:<br>
llvm/trunk/test/DebugInfo/X86/debug-macro.ll<br>
Modified:<br>
llvm/trunk/include/llvm/CodeGen/DIE.h<br>
llvm/trunk/include/llvm/MC/MCObjectFileInfo.h<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
llvm/trunk/lib/IR/Verifier.cpp<br>
llvm/trunk/lib/MC/MCObjectFileInfo.cpp<br>
llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp<br>
llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h<br>
<br>
Modified: llvm/trunk/include/llvm/CodeGen/DIE.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DIE.h?rev=257060&r1=257059&r2=257060&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DIE.h?rev=257060&r1=257059&r2=257060&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/CodeGen/DIE.h (original)<br>
+++ llvm/trunk/include/llvm/CodeGen/DIE.h Thu Jan 7 08:28:20 2016<br>
@@ -29,6 +29,48 @@ class MCSymbol;<br>
class raw_ostream;<br>
class DwarfTypeUnit;<br>
<br>
+// AsmStreamerBase - A base abstract interface class defines methods that<br>
+// can be implemented to stream objects or can be implemented to<br>
+// calculate the size of the streamed objects.<br>
+// The derived classes will use an AsmPrinter to implement the methods.<br>
+//<br>
+// TODO: complete this interface and use it to merge EmitValue and SizeOf<br>
+// methods in the DIE classes below.<br></blockquote><div><br></div><div>Adrian do you really reckon we need/want this abstraction?<br><br>I think this is a bit of a divergence from the way the rest of the DWARF emission is done, where we rely on relocations (most of which are resolved at object emission time - they aren't actually dynamic relocs) to compute the size/offsets of section contributions of DWARF to the CU, etc. Is there a reason that doesn't work/is worse/different in this case?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+class AsmStreamerBase {<br>
+protected:<br>
+ const AsmPrinter *AP;<br>
+ AsmStreamerBase(const AsmPrinter *AP) : AP(AP) {}<br>
+<br>
+public:<br>
+ virtual ~AsmStreamerBase() {}<br>
+ virtual unsigned emitULEB128(uint64_t Value, const char *Desc = nullptr,<br>
+ unsigned PadTo = 0) = 0;<br>
+ virtual unsigned emitInt8(unsigned char Value) = 0;<br>
+ virtual unsigned emitBytes(StringRef Data) = 0;<br>
+};<br>
+<br>
+/// EmittingAsmStreamer - Implements AbstractAsmStreamer to stream objects.<br>
+/// Notice that the return value is not the actual size of the streamed object.<br>
+/// For size calculation use SizeReporterAsmStreamer.<br>
+class EmittingAsmStreamer : public AsmStreamerBase {<br>
+public:<br>
+ EmittingAsmStreamer(const AsmPrinter *AP) : AsmStreamerBase(AP) {}<br>
+ unsigned emitULEB128(uint64_t Value, const char *Desc = nullptr,<br>
+ unsigned PadTo = 0) override;<br>
+ unsigned emitInt8(unsigned char Value) override;<br>
+ unsigned emitBytes(StringRef Data) override;<br>
+};<br>
+<br>
+/// SizeReporterAsmStreamer - Only reports the size of the streamed objects.<br>
+class SizeReporterAsmStreamer : public AsmStreamerBase {<br>
+public:<br>
+ SizeReporterAsmStreamer(const AsmPrinter *AP) : AsmStreamerBase(AP) {}<br>
+ unsigned emitULEB128(uint64_t Value, const char *Desc = nullptr,<br>
+ unsigned PadTo = 0) override;<br>
+ unsigned emitInt8(unsigned char Value) override;<br>
+ unsigned emitBytes(StringRef Data) override;<br>
+};<br>
+<br>
//===--------------------------------------------------------------------===//<br>
/// DIEAbbrevData - Dwarf abbreviation data, describes one attribute of a<br>
/// Dwarf abbreviation.<br>
<br>
Modified: llvm/trunk/include/llvm/MC/MCObjectFileInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectFileInfo.h?rev=257060&r1=257059&r2=257060&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectFileInfo.h?rev=257060&r1=257059&r2=257060&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/MC/MCObjectFileInfo.h (original)<br>
+++ llvm/trunk/include/llvm/MC/MCObjectFileInfo.h Thu Jan 7 08:28:20 2016<br>
@@ -92,6 +92,7 @@ protected:<br>
MCSection *DwarfLocSection;<br>
MCSection *DwarfARangesSection;<br>
MCSection *DwarfRangesSection;<br>
+ MCSection *DwarfMacinfoSection;<br>
// The pubnames section is no longer generated by default. The generation<br>
// can be enabled by a compiler flag.<br>
MCSection *DwarfPubNamesSection;<br>
@@ -245,6 +246,7 @@ public:<br>
MCSection *getDwarfLocSection() const { return DwarfLocSection; }<br>
MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }<br>
MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }<br>
+ MCSection *getDwarfMacinfoSection() const { return DwarfMacinfoSection; }<br>
<br>
// DWARF5 Experimental Debug Info Sections<br>
MCSection *getDwarfAccelNamesSection() const {<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=257060&r1=257059&r2=257060&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=257060&r1=257059&r2=257060&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Thu Jan 7 08:28:20 2016<br>
@@ -32,6 +32,39 @@<br>
using namespace llvm;<br>
<br>
//===----------------------------------------------------------------------===//<br>
+// EmittingAsmStreamer Implementation<br>
+//===----------------------------------------------------------------------===//<br>
+unsigned EmittingAsmStreamer::emitULEB128(uint64_t Value, const char *Desc,<br>
+ unsigned PadTo) {<br>
+ AP->EmitULEB128(Value, Desc, PadTo);<br>
+ return 0;</blockquote><div><br></div><div>This is a slightly quirky API - isn't it problematic for a caller, if they don't know which kind of AsmStreamer they're interacting with - and one produces sizes, the other produces zeros. That seems... not good?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+}<br>
+<br>
+unsigned EmittingAsmStreamer::emitInt8(unsigned char Value) {<br>
+ AP->EmitInt8(Value);<br>
+ return 0;<br>
+}<br>
+<br>
+unsigned EmittingAsmStreamer::emitBytes(StringRef Data) {<br>
+ AP->OutStreamer->EmitBytes(Data);<br>
+ return 0;<br>
+}<br>
+<br>
+//===----------------------------------------------------------------------===//<br>
+// SizeReporterAsmStreamer Implementation<br>
+//===----------------------------------------------------------------------===//<br>
+unsigned SizeReporterAsmStreamer::emitULEB128(uint64_t Value, const char *Desc,<br>
+ unsigned PadTo) {<br>
+ return getULEB128Size(Value);<br>
+}<br>
+<br>
+unsigned SizeReporterAsmStreamer::emitInt8(unsigned char Value) { return 1; }<br>
+<br>
+unsigned SizeReporterAsmStreamer::emitBytes(StringRef Data) {<br>
+ return Data.size();<br>
+}<br>
+<br>
+//===----------------------------------------------------------------------===//<br>
// DIEAbbrevData Implementation<br>
//===----------------------------------------------------------------------===//<br>
<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=257060&r1=257059&r2=257060&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=257060&r1=257059&r2=257060&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Jan 7 08:28:20 2016<br>
@@ -561,6 +561,8 @@ void DwarfDebug::finalizeModuleInfo() {<br>
// Collect info for variables that were optimized out.<br>
collectDeadVariables();<br>
<br>
+ unsigned MacroOffset = 0;<br>
+ std::unique_ptr<AsmStreamerBase> AS(new SizeReporterAsmStreamer(Asm));<br>
// Handle anything that needs to be done on a per-unit basis after<br>
// all other generation.<br>
for (const auto &P : CUMap) {<br>
@@ -613,6 +615,15 @@ void DwarfDebug::finalizeModuleInfo() {<br>
U.setBaseAddress(TheCU.getRanges().front().getStart());<br>
U.attachRangesOrLowHighPC(U.getUnitDie(), TheCU.takeRanges());<br>
}<br>
+<br>
+ auto *CUNode = cast<DICompileUnit>(P.first);<br>
+ if (CUNode->getMacros()) {<br>
+ // Compile Unit has macros, emit "DW_AT_macro_info" attribute.<br>
+ U.addUInt(U.getUnitDie(), dwarf::DW_AT_macro_info,<br>
+ dwarf::DW_FORM_sec_offset, MacroOffset);<br>
+ // Update macro section offset<br>
+ MacroOffset += handleMacroNodes(AS.get(), CUNode->getMacros(), U);<br>
+ }<br>
}<br>
<br>
// Compute DIE offsets and sizes.<br>
@@ -656,6 +667,9 @@ void DwarfDebug::endModule() {<br>
// Emit info into a debug ranges section.<br>
emitDebugRanges();<br>
<br>
+ // Emit info into a debug macinfo section.<br>
+ emitDebugMacinfo();<br>
+<br>
if (useSplitDwarf()) {<br>
emitDebugStrDWO();<br>
emitDebugInfoDWO();<br>
@@ -1833,6 +1847,70 @@ void DwarfDebug::emitDebugRanges() {<br>
}<br>
}<br>
<br>
+unsigned DwarfDebug::handleMacroNodes(AsmStreamerBase *AS,<br>
+ DIMacroNodeArray Nodes,<br>
+ DwarfCompileUnit &U) {<br>
+ unsigned Size = 0;<br>
+ for (auto *MN : Nodes) {<br>
+ if (auto *M = dyn_cast<DIMacro>(MN))<br>
+ Size += emitMacro(AS, *M);<br>
+ else if (auto *F = dyn_cast<DIMacroFile>(MN))<br>
+ Size += emitMacroFile(AS, *F, U);<br>
+ else<br>
+ llvm_unreachable("Unexpected DI type!");<br>
+ }<br>
+ return Size;<br>
+}<br>
+<br>
+unsigned DwarfDebug::emitMacro(AsmStreamerBase *AS, DIMacro &M) {<br>
+ int Size = 0;<br>
+ Size += AS->emitULEB128(M.getMacinfoType());<br>
+ Size += AS->emitULEB128(M.getLine());<br>
+ StringRef Name = M.getName();<br>
+ StringRef Value = M.getValue();<br>
+ Size += AS->emitBytes(Name);<br>
+ if (!Value.empty()) {<br>
+ // There should be one space between macro name and macro value.<br>
+ Size += AS->emitInt8(' ');<br>
+ Size += AS->emitBytes(Value);<br>
+ }<br>
+ Size += AS->emitInt8('\0');<br>
+ return Size;<br>
+}<br>
+<br>
+unsigned DwarfDebug::emitMacroFile(AsmStreamerBase *AS, DIMacroFile &F,<br>
+ DwarfCompileUnit &U) {<br>
+ int Size = 0;<br>
+ assert(F.getMacinfoType() == dwarf::DW_MACINFO_start_file);<br>
+ Size += AS->emitULEB128(dwarf::DW_MACINFO_start_file);<br>
+ Size += AS->emitULEB128(F.getLine());<br>
+ DIFile *File = F.getFile();<br>
+ unsigned FID =<br>
+ U.getOrCreateSourceID(File->getFilename(), File->getDirectory());<br>
+ Size += AS->emitULEB128(FID);<br>
+ Size += handleMacroNodes(AS, F.getElements(), U);<br>
+ Size += AS->emitULEB128(dwarf::DW_MACINFO_end_file);<br>
+ return Size;<br>
+}<br>
+<br>
+// Emit visible names into a debug macinfo section.<br>
+void DwarfDebug::emitDebugMacinfo() {<br>
+ if (MCSection *Macinfo = Asm->getObjFileLowering().getDwarfMacinfoSection()) {<br>
+ // Start the dwarf macinfo section.<br>
+ Asm->OutStreamer->SwitchSection(Macinfo);<br>
+ }<br>
+ std::unique_ptr<AsmStreamerBase> AS(new EmittingAsmStreamer(Asm));<br>
+ for (const auto &P : CUMap) {<br>
+ auto &TheCU = *P.second;<br>
+ auto *SkCU = TheCU.getSkeleton();<br>
+ DwarfCompileUnit &U = SkCU ? *SkCU : TheCU;<br>
+ auto *CUNode = cast<DICompileUnit>(P.first);<br>
+ handleMacroNodes(AS.get(), CUNode->getMacros(), U);<br>
+ }<br>
+ Asm->OutStreamer->AddComment("End Of Macro List Mark");<br>
+ Asm->EmitInt8(0);<br>
+}<br>
+<br>
// DWARF5 Experimental Separate Dwarf emitters.<br>
<br>
void DwarfDebug::initSkeletonUnit(const DwarfUnit &U, DIE &Die,<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=257060&r1=257059&r2=257060&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=257060&r1=257059&r2=257060&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Thu Jan 7 08:28:20 2016<br>
@@ -400,18 +400,26 @@ class DwarfDebug : public AsmPrinterHand<br>
/// Emit visible names into a debug str section.<br>
void emitDebugStr();<br>
<br>
- /// Emit visible names into a debug loc section.<br>
+ /// Emit variable locations into a debug loc section.<br>
void emitDebugLoc();<br>
<br>
- /// Emit visible names into a debug loc dwo section.<br>
+ /// Emit variable locations into a debug loc dwo section.<br>
void emitDebugLocDWO();<br>
<br>
- /// Emit visible names into a debug aranges section.<br>
+ /// Emit address ranges into a debug aranges section.<br>
void emitDebugARanges();<br>
<br>
- /// Emit visible names into a debug ranges section.<br>
+ /// Emit address ranges into a debug ranges section.<br>
void emitDebugRanges();<br>
<br>
+ /// Emit macros into a debug macinfo section.<br>
+ void emitDebugMacinfo();<br>
+ unsigned emitMacro(AsmStreamerBase *AS, DIMacro &M);<br>
+ unsigned emitMacroFile(AsmStreamerBase *AS, DIMacroFile &F,<br>
+ DwarfCompileUnit &U);<br>
+ unsigned handleMacroNodes(AsmStreamerBase *AS, DIMacroNodeArray Nodes,<br>
+ DwarfCompileUnit &U);<br>
+<br>
/// DWARF 5 Experimental Split Dwarf Emitters<br>
<br>
/// Initialize common features of skeleton units.<br>
<br>
Modified: llvm/trunk/lib/IR/Verifier.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=257060&r1=257059&r2=257060&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=257060&r1=257059&r2=257060&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/Verifier.cpp (original)<br>
+++ llvm/trunk/lib/IR/Verifier.cpp Thu Jan 7 08:28:20 2016<br>
@@ -984,6 +984,9 @@ void Verifier::visitDIMacro(const DIMacr<br>
N.getMacinfoType() == dwarf::DW_MACINFO_undef,<br>
"invalid macinfo type", &N);<br>
Assert(!N.getName().empty(), "anonymous macro", &N);<br>
+ if (!N.getValue().empty()) {<br>
+ assert(N.getValue().data()[0] != ' ' && "Macro value has a space prefix");<br>
+ }<br>
}<br>
<br>
void Verifier::visitDIMacroFile(const DIMacroFile &N) {<br>
<br>
Modified: llvm/trunk/lib/MC/MCObjectFileInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=257060&r1=257059&r2=257060&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=257060&r1=257059&r2=257060&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/MC/MCObjectFileInfo.cpp (original)<br>
+++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp Thu Jan 7 08:28:20 2016<br>
@@ -256,6 +256,9 @@ void MCObjectFileInfo::initMachOMCObject<br>
DwarfRangesSection =<br>
Ctx->getMachOSection("__DWARF", "__debug_ranges", MachO::S_ATTR_DEBUG,<br>
SectionKind::getMetadata(), "debug_range");<br>
+ DwarfMacinfoSection =<br>
+ Ctx->getMachOSection("__DWARF", "__debug_macinfo", MachO::S_ATTR_DEBUG,<br>
+ SectionKind::getMetadata());<br>
DwarfDebugInlineSection =<br>
Ctx->getMachOSection("__DWARF", "__debug_inlined", MachO::S_ATTR_DEBUG,<br>
SectionKind::getMetadata());<br>
@@ -505,6 +508,8 @@ void MCObjectFileInfo::initELFMCObjectFi<br>
Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0);<br>
DwarfRangesSection =<br>
Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0, "debug_range");<br>
+ DwarfMacinfoSection =<br>
+ Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0);<br>
<br>
// DWARF5 Experimental Debug Info<br>
<br>
@@ -684,6 +689,11 @@ void MCObjectFileInfo::initCOFFMCObjectF<br>
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |<br>
COFF::IMAGE_SCN_MEM_READ,<br>
SectionKind::getMetadata(), "debug_range");<br>
+ DwarfMacinfoSection = Ctx->getCOFFSection(<br>
+ ".debug_macinfo",<br>
+ COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |<br>
+ COFF::IMAGE_SCN_MEM_READ,<br>
+ SectionKind::getMetadata());<br>
DwarfInfoDWOSection = Ctx->getCOFFSection(<br>
".debug_info.dwo",<br>
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |<br>
<br>
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp?rev=257060&r1=257059&r2=257060&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp?rev=257060&r1=257059&r2=257060&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp (original)<br>
+++ llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp Thu Jan 7 08:28:20 2016<br>
@@ -4549,6 +4549,7 @@ NVPTXTargetObjectFile::~NVPTXTargetObjec<br>
delete static_cast<NVPTXSection *>(DwarfLocSection);<br>
delete static_cast<NVPTXSection *>(DwarfARangesSection);<br>
delete static_cast<NVPTXSection *>(DwarfRangesSection);<br>
+ delete static_cast<NVPTXSection *>(DwarfMacinfoSection);<br>
}<br>
<br>
MCSection *<br>
<br>
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h?rev=257060&r1=257059&r2=257060&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h?rev=257060&r1=257059&r2=257060&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h (original)<br>
+++ llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h Thu Jan 7 08:28:20 2016<br>
@@ -41,6 +41,7 @@ public:<br>
DwarfLocSection = nullptr;<br>
DwarfARangesSection = nullptr;<br>
DwarfRangesSection = nullptr;<br>
+ DwarfMacinfoSection = nullptr;<br>
}<br>
<br>
virtual ~NVPTXTargetObjectFile();<br>
@@ -81,6 +82,8 @@ public:<br>
new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());<br>
DwarfRangesSection =<br>
new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());<br>
+ DwarfMacinfoSection =<br>
+ new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());<br>
}<br>
<br>
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,<br>
<br>
Added: llvm/trunk/test/DebugInfo/X86/debug-macro.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/debug-macro.ll?rev=257060&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/debug-macro.ll?rev=257060&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/debug-macro.ll (added)<br>
+++ llvm/trunk/test/DebugInfo/X86/debug-macro.ll Thu Jan 7 08:28:20 2016<br>
@@ -0,0 +1,67 @@<br>
+; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck --check-prefix=CHECK-INFO %s<br>
+; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=macro - | FileCheck --check-prefix=CHECK-MACRO %s<br>
+; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=line - | FileCheck --check-prefix=CHECK-LINE %s<br>
+<br>
+<br>
+; CHECK-INFO: .debug_info contents:<br>
+; CHECK-INFO: DW_TAG_compile_unit<br>
+; CHECK-INFO-NOT: DW_TAG<br>
+; CHECK-INFO: DW_AT_name {{.*}}"debug-macro.cpp")<br>
+; CHECK-INFO: DW_AT_macro_info {{.*}}(0x00000000)<br>
+; CHECK-INFO: DW_TAG_compile_unit<br>
+; CHECK-INFO-NOT: DW_TAG<br>
+; CHECK-INFO: DW_AT_name {{.*}}"debug-macro1.cpp")<br>
+; CHECK-INFO: DW_AT_macro_info {{.*}}(0x00000044)<br>
+; CHECK-INFO: DW_TAG_compile_unit<br>
+; CHECK-INFO-NOT: DW_TAG<br>
+; CHECK-INFO: DW_AT_name {{.*}}"debug-macro2.cpp")<br>
+; CHECK-INFO-NOT: DW_AT_macro_info<br>
+<br>
+; CHECK-MACRO: .debug_macinfo contents:<br>
+; CHECK-MACRO-NEXT: DW_MACINFO_define - lineno: 0 macro: NameCMD ValueCMD<br>
+; CHECK-MACRO-NEXT: DW_MACINFO_start_file - lineno: 0 filenum: 1<br>
+; CHECK-MACRO-NEXT: DW_MACINFO_start_file - lineno: 9 filenum: 2<br>
+; CHECK-MACRO-NEXT: DW_MACINFO_define - lineno: 1 macro: NameDef Value<br>
+; CHECK-MACRO-NEXT: DW_MACINFO_undef - lineno: 11 macro: NameUndef<br>
+; CHECK-MACRO-NEXT: DW_MACINFO_end_file<br>
+; CHECK-MACRO-NEXT: DW_MACINFO_undef - lineno: 10 macro: NameUndef2<br>
+; CHECK-MACRO-NEXT: DW_MACINFO_end_file<br>
+; CHECK-MACRO-NEXT: DW_MACINFO_start_file - lineno: 0 filenum: 1<br>
+; CHECK-MACRO-NEXT: DW_MACINFO_end_file<br>
+<br>
+; CHECK-LINE: .debug_line contents:<br>
+; CHECK-LINE: Dir Mod Time File Len File Name<br>
+; CHECK-LINE: file_names[ 1] {{.*}}debug-macro.cpp<br>
+; CHECK-LINE: file_names[ 2] {{.*}}debug-macro.h<br>
+; CHECK-LINE: Dir Mod Time File Len File Name<br>
+; CHECK-LINE: file_names[ 1] {{.*}}debug-macro1.cpp<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0, !16, !20}<br>
+!llvm.module.flags = !{!13, !14}<br>
+!llvm.ident = !{!15}<br>
+<br>
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, subprograms: !2, globals: !2, imports: !2, macros: !3)<br>
+!1 = !DIFile(filename: "debug-macro.cpp", directory: "/")<br>
+!2 = !{}<br>
+!3 = !{!4, !5}<br>
+!4 = !DIMacro(type: DW_MACINFO_define, line: 0, name: "NameCMD", value: "ValueCMD")<br>
+!5 = !DIMacroFile(line: 0, file: !1, nodes: !6)<br>
+!6 = !{!7, !12}<br>
+!7 = !DIMacroFile(line: 9, file: !8, nodes: !9)<br>
+!8 = !DIFile(filename: "debug-macro.h", directory: "/")<br>
+!9 = !{!10, !11}<br>
+!10 = !DIMacro(type: DW_MACINFO_define, line: 1, name: "NameDef", value: "Value")<br>
+!11 = !DIMacro(type: DW_MACINFO_undef, line: 11, name: "NameUndef")<br>
+!12 = !DIMacro(type: DW_MACINFO_undef, line: 10, name: "NameUndef2")<br>
+<br>
+!13 = !{i32 2, !"Dwarf Version", i32 4}<br>
+!14 = !{i32 1, !"Debug Info Version", i32 3}<br>
+!15 = !{!"clang version 3.5.0 "}<br>
+<br>
+!16 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: 1, file: !17, enums: !2, retainedTypes: !2, subprograms: !2, globals: !2, imports: !2, macros: !18)<br>
+!17 = !DIFile(filename: "debug-macro1.cpp", directory: "/")<br>
+!18 = !{!19}<br>
+!19 = !DIMacroFile(line: 0, file: !17, nodes: !2)<br>
+<br>
+!20 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: 1, file: !21, enums: !2, retainedTypes: !2, subprograms: !2, globals: !2, imports: !2)<br>
+!21 = !DIFile(filename: "debug-macro2.cpp", directory: "/")<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>