<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Oct 7, 2013 at 12:33 PM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Mon, Oct 7, 2013 at 12:23 PM, Manman Ren <<a href="mailto:manman.ren@gmail.com">manman.ren@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
><br>
> On Fri, Oct 4, 2013 at 6:51 PM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>> wrote:<br>
>><br>
>> Can you please write a simple test case that tests this functionality?<br>
>> There seems to be no need to test it via a linked module. I'll review the<br>
>> rest later.<br>
><br>
><br>
> A simpler testing case can check that the backend can handle the case where<br>
> a derived-from field is a type identifier.<br>
> The added testing case can verify the same thing plus it can verify that we<br>
> can unique struct types containing a pointer type which points back to the<br>
> struct.<br>
><br>
> If the additional coverage is not needed, I can replace the added testing<br>
> cases with a single testing case.<br>
><br>
<br>
</div>Both are fine, but the linker test case doesn't actually test just the<br>
functionality in the patch.<br></blockquote><div><br></div><div>The struct has an integer field and a pointer field, I can remove the integer field if you think it is redundant to test other functionalities.</div><div><br>
</div><div>Manman</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
-eric<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> Thanks,<br>
> Manman<br>
><br>
>>> Added: llvm/trunk/test/Linker/Inputs/type-unique-simple2-a.ll<br>
>>> URL:<br>
>>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/Inputs/type-unique-simple2-a.ll?rev=192018&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/Inputs/type-unique-simple2-a.ll?rev=192018&view=auto</a><br>
>>><br>
>>> ==============================================================================<br>
>>> --- llvm/trunk/test/Linker/Inputs/type-unique-simple2-a.ll (added)<br>
>>> +++ llvm/trunk/test/Linker/Inputs/type-unique-simple2-a.ll Fri Oct 4<br>
>>> 20:43:03 2013<br>
>>> @@ -0,0 +1,83 @@<br>
>>> +; CHECK: 0x[[INT:.*]]: DW_TAG_base_type<br>
>>> +; CHECK-NEXT: DW_AT_name {{.*}} = "int"<br>
>>> +; CHECK-NOT: DW_TAG_base_type<br>
>>> +; CHECK: 0x[[BASE:.*]]: DW_TAG_structure_type<br>
>>> +; CHECK-NEXT: DW_AT_name {{.*}} = "Base"<br>
>>> +; CHECK-NOT: DW_TAG_structure_type<br>
>>> +; CHECK: DW_TAG_formal_parameter<br>
>>> +; CHECK: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[INT]])<br>
>>> +; CHECK: DW_TAG_variable<br>
>>> +; CHECK: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[BASE]])<br>
>>> +<br>
>>> +; LINK: DW_TAG_structure_type<br>
>>> +; LINK-NOT: DW_TAG_structure_type<br>
>>> +<br>
>>> +; Content of header files:<br>
>>> +; struct Base {<br>
>>> +; int a;<br>
>>> +; Base *b;<br>
>>> +; };<br>
>>> +; Content of foo.cpp:<br>
>>> +;<br>
>>> +; #include "a.hpp"<br>
>>> +; void f(int a) {<br>
>>> +; Base t;<br>
>>> +; }<br>
>>> +; Content of bar.cpp:<br>
>>> +;<br>
>>> +; #include "a.hpp"<br>
>>> +; void f(int);<br>
>>> +; void g(int a) {<br>
>>> +; Base t;<br>
>>> +; }<br>
>>> +; int main() {<br>
>>> +; f(0);<br>
>>> +; g(1);<br>
>>> +; return 0;<br>
>>> +; }<br>
>>> +; ModuleID = 'foo.cpp'<br>
>>> +<br>
>>> +%struct.Base = type { i32, %struct.Base* }<br>
>>> +<br>
>>> +; Function Attrs: nounwind ssp uwtable<br>
>>> +define void @_Z1fi(i32 %a) #0 {<br>
>>> +entry:<br>
>>> + %a.addr = alloca i32, align 4<br>
>>> + %t = alloca %struct.Base, align 8<br>
>>> + store i32 %a, i32* %a.addr, align 4<br>
>>> + call void @llvm.dbg.declare(metadata !{i32* %a.addr}, metadata !17),<br>
>>> !dbg !18<br>
>>> + call void @llvm.dbg.declare(metadata !{%struct.Base* %t}, metadata<br>
>>> !19), !dbg !20<br>
>>> + ret void, !dbg !21<br>
>>> +}<br>
>>> +<br>
>>> +; Function Attrs: nounwind readnone<br>
>>> +declare void @llvm.dbg.declare(metadata, metadata) #1<br>
>>> +<br>
>>> +attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false"<br>
>>> "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"<br>
>>> "no-infs-fp-math"="false" "no-nans-fp-math"="false"<br>
>>> "stack-protector-buffer-size"="8" "unsafe-fp-math"="false"<br>
>>> "use-soft-float"="false" }<br>
>>> +attributes #1 = { nounwind readnone }<br>
>>> +<br>
>>> +!<a href="http://llvm.dbg.cu" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
>>> +!llvm.module.flags = !{!16}<br>
>>> +<br>
>>> +!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version<br>
>>> 3.4 (<a href="http://llvm.org/git/clang.git" target="_blank">http://llvm.org/git/clang.git</a> 8a3f9e46cb988d2c664395b21910091e3730ae82)<br>
>>> (<a href="http://llvm.org/git/llvm.git" target="_blank">http://llvm.org/git/llvm.git</a> 4699e9549358bc77824a59114548eecc3f7c523c)", i1<br>
>>> false, metadata !"", i32 0, metadata !2, metadata !3, metadata !11, metadata<br>
>>> !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [foo.cpp]<br>
>>> [DW_LANG_C_plus_plus]<br>
>>> +!1 = metadata !{metadata !"foo.cpp", metadata !"."}<br>
>>> +!2 = metadata !{i32 0}<br>
>>> +!3 = metadata !{metadata !4}<br>
>>> +!4 = metadata !{i32 786451, metadata !5, null, metadata !"Base", i32 1,<br>
>>> i64 128, i64 64, i32 0, i32 0, null, metadata !6, i32 0, null, null,<br>
>>> metadata !"_ZTS4Base"} ; [ DW_TAG_structure_type ] [Base] [line 1, size 128,<br>
>>> align 64, offset 0] [def] [from ]<br>
>>> +!5 = metadata !{metadata !"./a.hpp", metadata !"."}<br>
>>> +!6 = metadata !{metadata !7, metadata !9}<br>
>>> +!7 = metadata !{i32 786445, metadata !5, metadata !"_ZTS4Base", metadata<br>
>>> !"a", i32 2, i64 32, i64 32, i64 0, i32 0, metadata !8} ; [ DW_TAG_member ]<br>
>>> [a] [line 2, size 32, align 32, offset 0] [from int]<br>
>>> +!8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32,<br>
>>> i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32,<br>
>>> align 32, offset 0, enc DW_ATE_signed]<br>
>>> +!9 = metadata !{i32 786445, metadata !5, metadata !"_ZTS4Base", metadata<br>
>>> !"b", i32 3, i64 64, i64 64, i64 64, i32 0, metadata !10} ; [ DW_TAG_member<br>
>>> ] [b] [line 3, size 64, align 64, offset 64] [from ]<br>
>>> +!10 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64,<br>
>>> i64 64, i64 0, i32 0, metadata !"_ZTS4Base"}<br>
>>> +!11 = metadata !{metadata !12}<br>
>>> +!12 = metadata !{i32 786478, metadata !1, metadata !13, metadata !"f",<br>
>>> metadata !"f", metadata !"_Z1fi", i32 3, metadata !14, i1 false, i1 true,<br>
>>> i32 0, i32 0, null, i32 256, i1 false, void (i32)* @_Z1fi, null, null,<br>
>>> metadata !2, i32 3} ; [ DW_TAG_subprogram ] [line 3] [def] [f]<br>
>>> +!13 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ]<br>
>>> [foo.cpp]<br>
>>> +!14 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0,<br>
>>> i64 0, i64 0, i32 0, null, metadata !15, i32 0, null, null, null} ; [<br>
>>> DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]<br>
>>> +!15 = metadata !{null, metadata !8}<br>
>>> +!16 = metadata !{i32 2, metadata !"Dwarf Version", i32 2}<br>
>>> +!17 = metadata !{i32 786689, metadata !12, metadata !"a", metadata !13,<br>
>>> i32 16777219, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [a] [line<br>
>>> 3]<br>
>>> +!18 = metadata !{i32 3, i32 0, metadata !12, null}<br>
>>> +!19 = metadata !{i32 786688, metadata !12, metadata !"t", metadata !13,<br>
>>> i32 4, metadata !4, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [t] [line 4]<br>
>>> +!20 = metadata !{i32 4, i32 0, metadata !12, null}<br>
>>> +!21 = metadata !{i32 5, i32 0, metadata !12, null}<br>
>>></div></div></blockquote></div></div></div>