<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 17, 2014 at 9:53 AM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br>
<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"><div class=""><br>
On Mar 17, 2014, at 0:16, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:<br>
<br>
> I've been reading the thread and I'm still uncertain what logic you<br>
> think is going on here - also the testcase isn't clear as to what<br>
> behavior you've changed there.<br>
><br>
> Could you explain more with the testcase what you're expecting to be<br>
> uniqued here?<br>
><br>
<br>
</div>Sure! Suppose we have two files that declare the same class (abbreviated, the full source code is in the comments in the test case):<br>
<br>
$cat a.cpp<br>
class A {<br>
int data;<br>
};<br>
<br>
void bar() {<br>
A a;<br>
}<br>
<br>
$ cat b.cpp<br>
class A {<br>
int data;<br>
};<br>
<br>
$ clang "-cc1" "-triple" "x86_64-apple-macosx10.9.0" "-emit-llvm" "-o" "a.ll" -gdwarf-2 "-x" "c++" "a.cpp" && clang-3.5 "-cc1" "-triple" "x86_64-apple-macosx10.9.0" "-emit-llvm" "-o" "b.ll" -gdwarf-2 "-x" "c++" "b.cpp" && llvm-link a.ll b.ll -S -o t.ll && llc -filetype=obj -O0 < t.ll > t.o && dwarfdump t.o<br>
<br>
We end up with two DW_TAG_member type DIEs (and two DW_TAG_classes) because their MDNodes are different, as they have a different decl_line and decl_file. The normal DIRef-based uniquing doesn’t work here, because they are emitted from the list of retained types in the compile unit, and the list of retained types can’t use DIRefs because then we would loose those MDNodes, since nothing is pointing to them any more.<br>
</blockquote><div><br></div><div>This commit is to solve the issue of emitting two class DIEs for the two DW_TAG_classes with the same type identifier, and commit <span style="font-size:13px;font-family:Helvetica">r203982 is to unique the two DW_TAG_members, right? The two class DIEs are generated because we emit one class DIE when visiting retained types of each CU.</span></div>
<div><span style="font-size:13px;font-family:Helvetica"><br></span></div><div><span style="font-size:13px;font-family:Helvetica">Thanks,</span></div><div><span style="font-size:13px;font-family:Helvetica">Manman</span></div>
<div><span style="font-size:13px;font-family:Helvetica"><br></span></div><div><span style="font-family:Helvetica;font-size:13px"><br></span></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">
r203983 counters this by uniting every type before emitting it, but as Manman pointed out, it is sufficient to do this for every retained type.<br>
<span class=""><font color="#888888"><br>
-- adrian<br>
</font></span><div class=""><div class="h5"><br>
> On Fri, Mar 14, 2014 at 4:08 PM, Adrian Prantl <<a href="mailto:aprantl@apple.com">aprantl@apple.com</a>> wrote:<br>
>> Author: adrian<br>
>> Date: Fri Mar 14 18:08:29 2014<br>
>> New Revision: 203983<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=203983&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=203983&view=rev</a><br>
>> Log:<br>
>> Debug info: Unique types before emitting them to DWARF, where applicable.<br>
>><br>
>> Modified:<br>
>> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
>> llvm/trunk/test/Linker/type-unique-odr-a.ll<br>
>><br>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=203983&r1=203982&r2=203983&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=203983&r1=203982&r2=203983&view=diff</a><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)<br>
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Fri Mar 14 18:08:29 2014<br>
>> @@ -958,6 +958,9 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const<br>
>> DIE *ContextDIE = getOrCreateContextDIE(Context);<br>
>> assert(ContextDIE);<br>
>><br>
>> + // Unique the type. This is a noop if the type has no unique identifier.<br>
>> + Ty = DIType(resolve(Ty.getRef()));<br>
>> +<br>
>> DIE *TyDIE = getDIE(Ty);<br>
>> if (TyDIE)<br>
>> return TyDIE;<br>
>><br>
>> Modified: llvm/trunk/test/Linker/type-unique-odr-a.ll<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/type-unique-odr-a.ll?rev=203983&r1=203982&r2=203983&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/type-unique-odr-a.ll?rev=203983&r1=203982&r2=203983&view=diff</a><br>
>> ==============================================================================<br>
>> --- llvm/trunk/test/Linker/type-unique-odr-a.ll (original)<br>
>> +++ llvm/trunk/test/Linker/type-unique-odr-a.ll Fri Mar 14 18:08:29 2014<br>
>> @@ -28,6 +28,10 @@<br>
>> ; CHECK-NEXT: DW_AT_MIPS_linkage_name {{.*}} "_ZL3barv"<br>
>> ; CHECK: DW_TAG_class_type<br>
>> ; CHECK-NEXT: DW_AT_name {{.*}} "A"<br>
>> +; CHECK-NOT: DW_TAG<br>
>> +; CHECK: DW_TAG_member<br>
>> +; CHECK-NEXT: DW_AT_name {{.*}} "data"<br>
>> +; CHECK-NOT: DW_TAG<br>
>> ; CHECK: DW_TAG_subprogram<br>
>> ; CHECK-NEXT: DW_AT_MIPS_linkage_name {{.*}} "_ZN1A6getFooEv"<br>
>> ; CHECK-NEXT: DW_AT_name {{.*}} "getFoo"<br>
>><br>
>><br>
>> _______________________________________________<br>
>> llvm-commits mailing list<br>
>> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div></div>