diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-17 02:30:20 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-17 02:30:20 +0000 |
commit | 05ebfd09382b8dc8cd26eaf8fb91fb73ce48290e (patch) | |
tree | 92e6efb5cab9251fd4ec1425cf2bc3be61340af2 /llvm/test | |
parent | 25fd344aa4d69b18b1328c0a8b89dc539506a582 (diff) | |
download | bcm5719-llvm-05ebfd09382b8dc8cd26eaf8fb91fb73ce48290e.tar.gz bcm5719-llvm-05ebfd09382b8dc8cd26eaf8fb91fb73ce48290e.zip |
IR: Use ODR to unique DICompositeType members
Merge members that are describing the same member of the same ODR type,
even if other bits differ. If the file or line differ, we don't care;
if anything else differs, it's an ODR violation (and we still don't
really care).
For DISubprogram declarations, this looks at the LinkageName and Scope.
For DW_TAG_member instances of DIDerivedType, this looks at the Name and
Scope. In both cases, we know that the Scope follows ODR rules if it
has a non-empty identifier.
llvm-svn: 266548
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/Assembler/dicompositetype-members.ll | 54 | ||||
-rw-r--r-- | llvm/test/Linker/type-unique-odr-a.ll | 4 |
2 files changed, 58 insertions, 0 deletions
diff --git a/llvm/test/Assembler/dicompositetype-members.ll b/llvm/test/Assembler/dicompositetype-members.ll new file mode 100644 index 00000000000..631023e7a55 --- /dev/null +++ b/llvm/test/Assembler/dicompositetype-members.ll @@ -0,0 +1,54 @@ +; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s +; RUN: verify-uselistorder %s + +; Anchor the order of the nodes. +!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17} + +; Some basic building blocks. +; CHECK: !0 = !DIBasicType +; CHECK-NEXT: !1 = !DIFile +; CHECK-NEXT: !2 = !DIFile +!0 = !DIBasicType(tag: DW_TAG_base_type, name: "name", size: 1, align: 2, encoding: DW_ATE_unsigned_char) +!1 = !DIFile(filename: "path/to/file", directory: "/path/to/dir") +!2 = !DIFile(filename: "path/to/other", directory: "/path/to/dir") + +; Define an identified type with fields and functions. +; CHECK-NEXT: !3 = !DICompositeType(tag: DW_TAG_structure_type, name: "has-uuid", +; CHECK-NEXT: !4 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !"has-uuid", file: !1 +; CHECK-NEXT: !5 = !DIDerivedType(tag: DW_TAG_member, name: "field2", scope: !"has-uuid", file: !1 +; CHECK-NEXT: !6 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !"has-uuid", file: !1 +; CHECK-NEXT: !7 = !DISubprogram(name: "foo", linkageName: "foo2", scope: !"has-uuid", file: !1 +!3 = !DICompositeType(tag: DW_TAG_structure_type, name: "has-uuid", file: !1, line: 2, size: 64, align: 32, identifier: "uuid") +!4 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !"has-uuid", file: !1, line: 4, baseType: !0, size: 32, align: 32, offset: 32) +!5 = !DIDerivedType(tag: DW_TAG_member, name: "field2", scope: !"has-uuid", file: !1, line: 4, baseType: !0, size: 32, align: 32, offset: 32) +!6 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !"has-uuid", file: !1, isDefinition: false) +!7 = !DISubprogram(name: "foo", linkageName: "foo2", scope: !"has-uuid", file: !1, isDefinition: false) + +; Define an un-identified type with fields and functions. +; CHECK-NEXT: !8 = !DICompositeType(tag: DW_TAG_structure_type, name: "no-uuid", file: !1 +; CHECK-NEXT: !9 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !8, file: !1 +; CHECK-NEXT: !10 = !DIDerivedType(tag: DW_TAG_member, name: "field2", scope: !8, file: !1 +; CHECK-NEXT: !11 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !8, file: !1 +; CHECK-NEXT: !12 = !DISubprogram(name: "foo", linkageName: "foo2", scope: !8, file: !1 +!8 = !DICompositeType(tag: DW_TAG_structure_type, name: "no-uuid", file: !1, line: 2, size: 64, align: 32) +!9 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !8, file: !1, line: 4, baseType: !0, size: 32, align: 32, offset: 32) +!10 = !DIDerivedType(tag: DW_TAG_member, name: "field2", scope: !8, file: !1, line: 4, baseType: !0, size: 32, align: 32, offset: 32) +!11 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !8, file: !1, isDefinition: false) +!12 = !DISubprogram(name: "foo", linkageName: "foo2", scope: !8, file: !1, isDefinition: false) + +; Add duplicate fields and members of "no-uuid" in a different file. These +; should stick around, since "no-uuid" does not have an "identifier:" field. +; CHECK-NEXT: !13 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !8, file: !2, +; CHECK-NEXT: !14 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !8, file: !2, +!13 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !8, file: !2, line: 4, baseType: !0, size: 32, align: 32, offset: 32) +!14 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !8, file: !2, isDefinition: false) + +; Add duplicate fields and members of "has-uuid" in a different file. These +; should be merged. +!15 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !"has-uuid", file: !2, line: 4, baseType: !0, size: 32, align: 32, offset: 32) +!16 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !"has-uuid", file: !2, isDefinition: false) + +; CHECK-NEXT: !15 = !{!4, !6} +; CHECK-NOT: !DIDerivedType +; CHECK-NOT: !DISubprogram +!17 = !{!15, !16} diff --git a/llvm/test/Linker/type-unique-odr-a.ll b/llvm/test/Linker/type-unique-odr-a.ll index eeb1db763eb..d7640ea761c 100644 --- a/llvm/test/Linker/type-unique-odr-a.ll +++ b/llvm/test/Linker/type-unique-odr-a.ll @@ -4,6 +4,10 @@ ; RUN: | %llc_dwarf -dwarf-linkage-names=Enable -filetype=obj -O0 \ ; RUN: | llvm-dwarfdump -debug-dump=info - \ ; RUN: | FileCheck %s +; RUN: llvm-link %p/type-unique-odr-b.ll %s -S -o - \ +; RUN: | %llc_dwarf -dwarf-linkage-names=Enable -filetype=obj -O0 \ +; RUN: | llvm-dwarfdump -debug-dump=info - \ +; RUN: | FileCheck %s ; ; Test ODR-based type uniquing for C++ class members. ; rdar://problem/15851313. |