<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 12, 2014, at 4:40 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Wed, Nov 12, 2014 at 3:48 PM, Frederic Riss<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:friss@apple.com" target="_blank" class="">friss@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">Author: friss<br class="">Date: Wed Nov 12 17:48:14 2014<br class="">New Revision: 221837<br class=""><br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=221837&view=rev" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=221837&view=rev</a><br class="">Log:<br class="">Fix emission of Dwarf accelerator table when there are multiple CUs.<br class=""><br class="">The DIE offset in the accel tables is an offset relative to the start<br class="">of the debug_info section, but we were encoding the offset to the<br class="">start of the containing CU.<br class=""><br class="">Modified:<br class=""> <span class="Apple-converted-space"> </span>llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp<br class=""> <span class="Apple-converted-space"> </span>llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.h<br class=""> <span class="Apple-converted-space"> </span>llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br class=""> <span class="Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/cross-cu-inlining.ll<br class=""><br class="">Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp?rev=221837&r1=221836&r2=221837&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp?rev=221837&r1=221836&r2=221837&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp (original)<br class="">+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp Wed Nov 12 17:48:14 2014<br class="">@@ -13,6 +13,7 @@<br class=""><br class=""> #include "DwarfAccelTable.h"<br class=""> #include "DIE.h"<br class="">+#include "DwarfCompileUnit.h"<br class=""> #include "DwarfDebug.h"<br class=""> #include "llvm/ADT/STLExtras.h"<br class=""> #include "llvm/ADT/Twine.h"<br class="">@@ -174,7 +175,7 @@ void DwarfAccelTable::EmitOffsets(AsmPri<br class=""> // Walk through the buckets and emit the full data for each element in<br class=""> // the bucket. For the string case emit the dies and the various offsets.<br class=""> // Terminate each HashData bucket with 0.<br class="">-void DwarfAccelTable::EmitData(AsmPrinter *Asm, DwarfFile *D,<br class="">+void DwarfAccelTable::EmitData(AsmPrinter *Asm, DwarfDebug *D,<br class=""> <span class="Apple-converted-space"> </span>MCSymbol *StrSym) {<br class=""> uint64_t PrevHash = UINT64_MAX;<br class=""> for (size_t i = 0, e = Buckets.size(); i < e; ++i) {<br class="">@@ -189,7 +190,9 @@ void DwarfAccelTable::EmitData(AsmPrinte<br class=""> Asm->EmitInt32((*HI)->Data.Values.size());<br class=""> for (HashDataContents *HD : (*HI)->Data.Values) {<br class=""> // Emit the DIE offset<br class="">- Asm->EmitInt32(HD->Die->getOffset());<br class="">+ DwarfCompileUnit *CU = D->lookupUnit(HD->Die->getUnit());<br class=""></blockquote><div class=""><br class=""></div><div class="">'getUnit()' isn't the cheapest operation (having to walk the DIE tree checking for the top level unit kind) if it can be avoided (& then the extra map lookup too) - just FYI in case there's a nicer way to do this (should we record the DWARF*Unit in the record when we insert it instead?)<br class=""><br class="">No big deal - just a thought.</div></div></div></blockquote><div><br class=""></div><div>Mmmmh. Storing the Unit when we register the accelerator is a good idea. I thought about adding a Unit field to the DIE when writing this fix exactly to avoid the getUnit() lookup, but knowing that the DIEs account for a lot of memory already I didn’t do it. Paying the price in the AccelTable object it self should be fine though.</div><div><br class=""></div><div>Fred</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">+ assert(CU && "Accelerated DIE should belong to a CU.");<br class="">+ Asm->EmitInt32(HD->Die->getOffset() + CU->getDebugInfoOffset());<br class=""> // If we have multiple Atoms emit that info too.<br class=""> // FIXME: A bit of a hack, we either emit only one atom or all info.<br class=""> if (HeaderData.Atoms.size() > 1) {<br class="">@@ -206,7 +209,7 @@ void DwarfAccelTable::EmitData(AsmPrinte<br class=""> }<br class=""><br class=""> // Emit the entire data structure to the output file.<br class="">-void DwarfAccelTable::Emit(AsmPrinter *Asm, MCSymbol *SecBegin, DwarfFile *D,<br class="">+void DwarfAccelTable::Emit(AsmPrinter *Asm, MCSymbol *SecBegin, DwarfDebug *D,<br class=""> <span class="Apple-converted-space"> </span>MCSymbol *StrSym) {<br class=""> // Emit the header.<br class=""> EmitHeader(Asm);<br class=""><br class="">Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.h<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.h?rev=221837&r1=221836&r2=221837&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.h?rev=221837&r1=221836&r2=221837&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.h (original)<br class="">+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.h Wed Nov 12 17:48:14 2014<br class="">@@ -62,7 +62,7 @@<br class=""> namespace llvm {<br class=""><br class=""> class AsmPrinter;<br class="">-class DwarfFile;<br class="">+class DwarfDebug;<br class=""><br class=""> class DwarfAccelTable {<br class=""><br class="">@@ -223,7 +223,7 @@ private:<br class=""> void EmitBuckets(AsmPrinter *);<br class=""> void EmitHashes(AsmPrinter *);<br class=""> void EmitOffsets(AsmPrinter *, MCSymbol *);<br class="">- void EmitData(AsmPrinter *, DwarfFile *D, MCSymbol *StrSym);<br class="">+ void EmitData(AsmPrinter *, DwarfDebug *D, MCSymbol *StrSym);<br class=""><br class=""> // Allocator for HashData and HashDataContents.<br class=""> BumpPtrAllocator Allocator;<br class="">@@ -248,7 +248,7 @@ public:<br class=""> void AddName(StringRef Name, MCSymbol *StrSym, const DIE *Die,<br class=""> <span class="Apple-converted-space"> </span>char Flags = 0);<br class=""> void FinalizeTable(AsmPrinter *, StringRef);<br class="">- void Emit(AsmPrinter *, MCSymbol *, DwarfFile *, MCSymbol *StrSym);<br class="">+ void Emit(AsmPrinter *, MCSymbol *, DwarfDebug *, MCSymbol *StrSym);<br class=""> #ifndef NDEBUG<br class=""> void print(raw_ostream &O);<br class=""> void dump() { print(dbgs()); }<br class=""><br class="">Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=221837&r1=221836&r2=221837&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=221837&r1=221836&r2=221837&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br class="">+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Nov 12 17:48:14 2014<br class="">@@ -1478,7 +1478,7 @@ void DwarfDebug::emitAccel(DwarfAccelTab<br class=""> Asm->OutStreamer.EmitLabel(SectionBegin);<br class=""><br class=""> // Emit the full data.<br class="">- Accel.Emit(Asm, SectionBegin, &InfoHolder, DwarfStrSectionSym);<br class="">+ Accel.Emit(Asm, SectionBegin, this, DwarfStrSectionSym);<br class=""> }<br class=""><br class=""> // Emit visible names into a hashed accelerator table section.<br class=""><br class="">Modified: llvm/trunk/test/DebugInfo/cross-cu-inlining.ll<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/cross-cu-inlining.ll?rev=221837&r1=221836&r2=221837&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/cross-cu-inlining.ll?rev=221837&r1=221836&r2=221837&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/test/DebugInfo/cross-cu-inlining.ll (original)<br class="">+++ llvm/trunk/test/DebugInfo/cross-cu-inlining.ll Wed Nov 12 17:48:14 2014<br class="">@@ -1,6 +1,7 @@<br class=""> ; REQUIRES: object-emission<br class=""><br class=""> ; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck -implicit-check-not=DW_TAG %s<br class="">+; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump - | FileCheck --check-prefix=CHECK-ACCEL --check-prefix=CHECK %s<br class=""><br class=""> ; Build from source:<br class=""> ; $ clang++ a.cpp b.cpp -g -c -emit-llvm<br class="">@@ -24,7 +25,7 @@<br class=""> ; CHECK: DW_AT_name {{.*}} "a.cpp"<br class=""> ; CHECK: DW_TAG_subprogram<br class=""> ; CHECK: DW_AT_type [DW_FORM_ref_addr] (0x00000000[[INT:.*]])<br class="">-; CHECK: DW_TAG_inlined_subroutine<br class="">+; CHECK: 0x[[INLINED:[0-9a-f]*]]:{{.*}}DW_TAG_inlined_subroutine<br class=""> ; CHECK: DW_AT_abstract_origin {{.*}}[[ABS_FUNC:........]] "_Z4funci"<br class=""> ; CHECK: DW_TAG_formal_parameter<br class=""> ; CHECK: DW_AT_abstract_origin {{.*}}[[ABS_VAR:........]] "x"<br class="">@@ -45,13 +46,24 @@<br class=""><br class=""> ; Check the concrete out of line definition references the abstract and<br class=""> ; provides the address range and variable location<br class="">-; CHECK: DW_TAG_subprogram<br class="">+; CHECK: 0x[[FUNC:[0-9a-f]*]]{{.*}}DW_TAG_subprogram<br class=""></blockquote><div class=""><br class="">I tend to prefer to include the 0x in the match, just to make sure the later backreference doesn't have any other junk preceeding it, etc.<br class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"> ; CHECK: DW_AT_low_pc<br class=""> ; CHECK: DW_AT_abstract_origin {{.*}} {0x[[ABS_FUNC]]} "_Z4funci"<br class=""> ; CHECK: DW_TAG_formal_parameter<br class=""> ; CHECK: DW_AT_location<br class=""> ; CHECK: DW_AT_abstract_origin {{.*}} {0x[[ABS_VAR]]} "x"<br class=""><br class="">+; CHECK-ACCEL: .apple_names contents:<br class="">+; CHECK-ACCEL: Name{{.*}}"func"<br class="">+; CHECK-ACCEL-NOT: Name<br class="">+; CHECK-ACCEL: Atom[0]{{.*}}[[INLINED]]<br class="">+; CHECK-ACCEL-NOT: Name<br class="">+; CHECK-ACCEL: Atom[0]{{.*}}[[FUNC]]<br class="">+<br class="">+; CHECK-ACCEL: .apple_types contents:<br class="">+; CHECK-ACCEL: Name{{.*}}"int"<br class="">+; CHECK-ACCEL-NOT: Name<br class="">+; CHECK-ACCEL: Atom[0]{{.*}}[[INT]]<br class=""></blockquote><div class=""><br class="">I'm assuming not all 3 of these elements were in the non-first CU, so some of these tests could've been added separately? (ie: they were already passing before your fix in this commit)<br class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><br class=""> @i = external global i32<br class=""><br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@cs.uiuc.edu" class="">llvm-commits@cs.uiuc.edu</a><br class=""><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></blockquote></div></div></blockquote></div><br class=""></body></html>