summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2016-12-16 21:25:01 +0000
committerTeresa Johnson <tejohnson@google.com>2016-12-16 21:25:01 +0000
commita61f5e379675732666744bcba25efbc9922e016a (patch)
treee9fca58ec6916e678a6fc2d90bb2b00c3846c0e5 /llvm/test
parent3ca147ea3d8c2364542c2e4c2b7ba83fdf5e6dcd (diff)
downloadbcm5719-llvm-a61f5e379675732666744bcba25efbc9922e016a.tar.gz
bcm5719-llvm-a61f5e379675732666744bcba25efbc9922e016a.zip
[ThinLTO] Import composite types as declarations
Summary: When reading the metadata bitcode, create a type declaration when possible for composite types when we are importing. Doing this in the bitcode reader saves memory. Also it works naturally in the case when the type ODR map contains a definition for the same composite type because it was used in the importing module (buildODRType will automatically use the existing definition and not create a type declaration). For Chromium built with -g2, this reduces the aggregate size of the generated native object files by 66% (from 31G to 10G). It reduced the time through the ThinLTO link and backend phases by about 20% on my machine. Reviewers: mehdi_amini, dblaikie, aprantl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D27775 llvm-svn: 289993
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/ThinLTO/X86/Inputs/debuginfo-compositetype-import.ll13
-rw-r--r--llvm/test/ThinLTO/X86/debuginfo-compositetype-import.ll62
2 files changed, 75 insertions, 0 deletions
diff --git a/llvm/test/ThinLTO/X86/Inputs/debuginfo-compositetype-import.ll b/llvm/test/ThinLTO/X86/Inputs/debuginfo-compositetype-import.ll
new file mode 100644
index 00000000000..7e80c4d7c44
--- /dev/null
+++ b/llvm/test/ThinLTO/X86/Inputs/debuginfo-compositetype-import.ll
@@ -0,0 +1,13 @@
+; ModuleID = 'debuginfo-compositetype-import2.c'
+source_filename = "debuginfo-compositetype-import2.c"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: nounwind uwtable
+define i32 @main() {
+entry:
+ call void (...) @foo()
+ ret i32 0
+}
+
+declare void @foo(...) #1
diff --git a/llvm/test/ThinLTO/X86/debuginfo-compositetype-import.ll b/llvm/test/ThinLTO/X86/debuginfo-compositetype-import.ll
new file mode 100644
index 00000000000..0b3a7a45224
--- /dev/null
+++ b/llvm/test/ThinLTO/X86/debuginfo-compositetype-import.ll
@@ -0,0 +1,62 @@
+; Test to ensure DICompositeType are imported as type declarations
+; for ThinLTO
+
+; RUN: opt -module-summary %s -o %t1.bc
+; RUN: opt -module-summary %p/Inputs/debuginfo-compositetype-import.ll -o %t2.bc
+; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %t1.bc %t2.bc
+
+; By default, composite types are imported as type declarations
+; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t.index.bc -o - | llvm-dis -o - | FileCheck %s
+; RUN: llvm-lto2 %t1.bc %t2.bc -o %t.out -save-temps \
+; RUN: -r %t2.bc,main,plx \
+; RUN: -r %t2.bc,foo,l \
+; RUN: -r %t1.bc,foo,pl
+; RUN: llvm-dis < %t.out.1.3.import.bc | FileCheck %s
+
+; CHECK: distinct !DICompositeType(tag: DW_TAG_enumeration_type, name: "enum", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 50, size: 32, flags: DIFlagFwdDecl, identifier: "enum")
+; CHECK: distinct !DICompositeType(tag: DW_TAG_class_type, name: "class", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 728, size: 448, flags: DIFlagFwdDecl, identifier: "class")
+; CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "struct", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 309, size: 128, flags: DIFlagFwdDecl, identifier: "list")
+; CHECK: distinct !DICompositeType(tag: DW_TAG_union_type, file: !{{[0-9]+}}, line: 115, size: 384, flags: DIFlagFwdDecl, identifier: "union")
+
+; Ensure that full type definitions of composite types are imported if requested
+; RUN: llvm-lto -import-full-type-definitions -thinlto-action=import %t2.bc -thinlto-index=%t.index.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=FULL
+; RUN: llvm-lto2 %t1.bc %t2.bc -o %t.out -save-temps \
+; RUN: -import-full-type-definitions \
+; RUN: -r %t2.bc,main,plx \
+; RUN: -r %t2.bc,foo,l \
+; RUN: -r %t1.bc,foo,pl
+; RUN: llvm-dis < %t.out.1.3.import.bc | FileCheck %s --check-prefix=FULL
+
+; FULL: distinct !DICompositeType(tag: DW_TAG_enumeration_type, name: "enum", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 50, size: 32, elements: !{{[0-9]+}}, identifier: "enum")
+; FULL: distinct !DICompositeType(tag: DW_TAG_class_type, name: "class", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 728, size: 448, elements: !{{[0-9]+}}, identifier: "class")
+; FULL: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "struct", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 309, baseType: !{{[0-9]+}}, size: 128, offset: 64, elements: !{{[0-9]+}}, vtableHolder: !{{[0-9]+}}, templateParams: !{{[0-9]+}}, identifier: "list")
+; FULL: distinct !DICompositeType(tag: DW_TAG_union_type, file: !{{[0-9]+}}, line: 115, size: 384, elements: !{{[0-9]+}}, identifier: "union")
+
+; ModuleID = 'debuginfo-compositetype-import.c'
+source_filename = "debuginfo-compositetype-import.c"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: nounwind uwtable
+define void @foo() #0 !dbg !6 {
+entry:
+ ret void
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3}
+!llvm.ident = !{!4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 4.0.0 (trunk 286863) (llvm/trunk 286875)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
+!1 = !DIFile(filename: "debuginfo-compositetype-import.c", directory: "")
+!2 = !{i32 2, !"Dwarf Version", i32 4}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{!"clang version 4.0.0 (trunk 286863) (llvm/trunk 286875)"}
+!5 = !{}
+!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, variables: !5)
+!7 = !DISubroutineType(types: !8)
+!8 = !{!9, !10, !11, !12}
+!9 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "enum", scope: !1, file: !1, line: 50, size: 32, elements: !5, identifier: "enum")
+!10 = !DICompositeType(tag: DW_TAG_class_type, name: "class", scope: !1, file: !1, line: 728, size: 448, elements: !5, identifier: "class")
+!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "struct", scope: !1, file: !1, line: 309, baseType: !10, size: 128, offset: 64, elements: !5, vtableHolder: !10, templateParams: !5, identifier: "list")
+!12 = distinct !DICompositeType(tag: DW_TAG_union_type, file: !1, line: 115, size: 384, elements: !5, identifier: "union")
OpenPOWER on IntegriCloud