<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Helvetica;
panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.apple-converted-space
{mso-style-name:apple-converted-space;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Thanks for the feedback David.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I will work on a fix ASAP.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Amjad<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></a></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> aprantl@apple.com [mailto:aprantl@apple.com]
<br>
<b>Sent:</b> Thursday, January 14, 2016 01:19<br>
<b>To:</b> David Blaikie<br>
<b>Cc:</b> Aboud, Amjad; llvm-commits<br>
<b>Subject:</b> Re: [llvm] r257060 - Added support for macro emission in dwarf (supporting DWARF version 4).<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Jan 13, 2016, at 3:09 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">On Thu, Jan 7, 2016 at 6:28 AM, Amjad Aboud via llvm-commits<span class="apple-converted-space"> </span><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>><span class="apple-converted-space"> </span>wrote:<o:p></o:p></span></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">Author: aaboud<br>
Date: Thu Jan 7 08:28:20 2016<br>
New Revision: 257060<br>
<br>
URL:<span class="apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=257060&view=rev" 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:<span class="apple-converted-space"> </span><a href="http://reviews.llvm.org/D15495" target="_blank">http://reviews.llvm.org/D15495</a><br>
<br>
Added:<br>
<span class="apple-converted-space"> </span>llvm/trunk/test/DebugInfo/X86/debug-macro.ll<br>
Modified:<br>
<span class="apple-converted-space"> </span>llvm/trunk/include/llvm/CodeGen/DIE.h<br>
<span class="apple-converted-space"> </span>llvm/trunk/include/llvm/MC/MCObjectFileInfo.h<br>
<span class="apple-converted-space"> </span>llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp<br>
<span class="apple-converted-space"> </span>llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
<span class="apple-converted-space"> </span>llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
<span class="apple-converted-space"> </span>llvm/trunk/lib/IR/Verifier.cpp<br>
<span class="apple-converted-space"> </span>llvm/trunk/lib/MC/MCObjectFileInfo.cpp<br>
<span class="apple-converted-space"> </span>llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp<br>
<span class="apple-converted-space"> </span>llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h<br>
<br>
Modified: llvm/trunk/include/llvm/CodeGen/DIE.h<br>
URL:<span class="apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DIE.h?rev=257060&r1=257059&r2=257060&view=diff" 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.<o:p></o:p></span></p>
</blockquote>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">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?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"> <o:p></o:p></span></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">+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:<span class="apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectFileInfo.h?rev=257060&r1=257059&r2=257060&view=diff" 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:<span class="apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=257060&r1=257059&r2=257060&view=diff" 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;<o:p></o:p></span></p>
</blockquote>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">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?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"> <o:p></o:p></span></p>
</div>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Yeah I think you’re right. Using compile-time-resolved labels to compute the sizes is superior to this.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">-- adrian<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">+}<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:<span class="apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=257060&r1=257059&r2=257060&view=diff" 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:<span class="apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=257060&r1=257059&r2=257060&view=diff" 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:<span class="apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=257060&r1=257059&r2=257060&view=diff" 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>
<span class="apple-converted-space"> </span>N.getMacinfoType() == dwarf::DW_MACINFO_undef,<br>
<span class="apple-converted-space"> </span>"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:<span class="apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=257060&r1=257059&r2=257060&view=diff" 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>
<span class="apple-converted-space"> </span>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>
<span class="apple-converted-space"> </span>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:<span class="apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp?rev=257060&r1=257059&r2=257060&view=diff" 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:<span class="apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h?rev=257060&r1=257059&r2=257060&view=diff" 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:<span class="apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/debug-macro.ll?rev=257060&view=auto" 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/" target="_blank">llvm.dbg.cu</a><span class="apple-converted-space"> </span>= !{!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" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><o:p></o:p></span></p>
</blockquote>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p>---------------------------------------------------------------------<br>
Intel Israel (74) Limited</p>
<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.</p></body>
</html>