brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.5 KiB · 8d2af08 Raw
179 lines · plain
1; RUN: llc -mtriple=x86_64-linux -split-dwarf-cross-cu-references -split-dwarf-file=foo.dwo -filetype=obj -o %t < %s2; RUN: llvm-objdump -r %t | FileCheck --check-prefix=CHECK --check-prefix=RELO_CROSS %s3; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck --check-prefix=ALL --check-prefix=DWO --check-prefix=CROSS %s4; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck --check-prefix=ALL %s5 6; RUN: llc -mtriple=x86_64-linux -split-dwarf-file=foo.dwo -filetype=obj -o %t < %s7; RUN: llvm-objdump -r %t | FileCheck --check-prefix=CHECK %s8; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck --check-prefix=ALL --check-prefix=DWO --check-prefix=NOCROSS %s9; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck --check-prefix=ALL %s10 11; Testing cross-CU references for types, subprograms, and variables12; Built from code something like this:13; foo.cpp:14;   struct t1 { int i; };15;   void f();16;   __attribute__((always_inline)) void f1(t1 t) {17;     f();18;   }19;   void foo(t1 t) {20;     f1(t);21;   }22; bar.cpp:23;   struct t1 { int i; };24;   void f1(t1);25;   void bar(t1 t) {26;     f1(t);27;   }28; $ clang++-tot -emit-llvm -S {foo,bar}.cpp -g29; $ llvm-link-tot {foo,bar}.ll -S -o foobar.ll30; $ clang++-tot -emit-llvm foobar.ll -o foobar.opt.ll -S -c31;32; Then manually removing the original f1 definition, to simplify the DWARF a bit33; (so it only has the inlined definitions, no concrete definition)34 35; Check that:36; * no relocations are emitted for the debug_info.dwo section no matter what37; * one debug_info->debug_info relocation in debug_info no matter what (for38;   split dwarf inlining)39; * debug_info uses relocations and ref_addr no matter what40; * debug_info.dwo uses relocations for types as well as abstract subprograms41;   and variables when -split-dwarf-cross-cu-references is used42; * debug_info.dwo contains duplicate types, abstract subprograms and abstract43;   variables otherwise to avoid the need for cross-cu references44 45; DWO: .debug_info.dwo contents:46; CHECK-NOT: .rel{{a?}}.debug_info.dwo47; CHECK: RELOCATION RECORDS FOR [.debug_info]:48; CHECK-NOT: RELOCATION RECORDS49; Expect one relocation in debug_info, from the inlined f1 in foo to its50; abstract origin in bar51; RELO_CROSS: R_X86_64_32 .debug_info52; Expect no relocations in debug_info when disabling multiple CUs in Split DWARF53; CHECK-NOT: .debug_info54; CHECK: RELOCATION RECORDS55; CHECK-NOT: .rel{{a?}}.debug_info.dwo56 57; ALL: Compile Unit58; ALL: DW_TAG_compile_unit59; DWO:   DW_AT_name {{.*}} "foo.cpp"60; ALL: 0x[[F1:.*]]: DW_TAG_subprogram61; ALL:     DW_AT_name {{.*}} "f1"62; DWO: 0x[[F1T:.*]]: DW_TAG_formal_parameter63; DWO:       DW_AT_name {{.*}} "t"64; DWO:       DW_AT_type [DW_FORM_ref4] {{.*}}{0x[[T1:.*]]}65; DWO:     NULL66; DWO: 0x[[T1]]: DW_TAG_structure_type67; DWO:     DW_AT_name {{.*}} "t1"68; ALL:   DW_TAG_subprogram69; ALL:     DW_AT_name {{.*}} "foo"70; DWO:     DW_TAG_formal_parameter71; DWO:       DW_AT_name {{.*}} "t"72; DWO:       DW_AT_type [DW_FORM_ref4] {{.*}}{0x[[T1]]}73; ALL:     DW_TAG_inlined_subroutine74; ALL:       DW_AT_abstract_origin [DW_FORM_ref4] {{.*}}{0x[[F1]]}75; DWO:       DW_TAG_formal_parameter76; DWO:         DW_AT_abstract_origin [DW_FORM_ref4] {{.*}}{0x[[F1T]]}77 78; NOCROSS-NOT: DW_TAG_compile_unit79; CROSS: Compile Unit80; CROSS: DW_TAG_compile_unit81; CROSS:   DW_AT_name {{.*}} "bar.cpp"82; ALL:   DW_TAG_subprogram83; ALL:     DW_AT_name {{.*}} "bar"84; DWO:     DW_TAG_formal_parameter85; DWO:       DW_AT_name {{.*}} "t"86; CROSS:     DW_AT_type [DW_FORM_ref_addr] (0x00000000[[T1]]87; NOCROSS:   DW_AT_type [DW_FORM_ref4] {{.*}}{0x[[T1]]}88; ALL:     DW_TAG_inlined_subroutine89; CROSS:     DW_AT_abstract_origin [DW_FORM_ref_addr] (0x00000000[[F1]]90; NOCROSS:   DW_AT_abstract_origin [DW_FORM_ref4] {{.*}}{0x[[F1]]}91; DWO:       DW_TAG_formal_parameter92; CROSS:       DW_AT_abstract_origin [DW_FORM_ref_addr] (0x00000000[[F1T]]93; NOCROSS:     DW_AT_abstract_origin [DW_FORM_ref4] {{.*}}{0x[[F1T]]94 95%struct.t1 = type { i32 }96 97; Function Attrs: nounwind readnone speculatable98declare void @llvm.dbg.declare(metadata, metadata, metadata) #199 100declare void @_Z1fv() #2101 102; Function Attrs: noinline uwtable103define void @_Z3foo2t1(i32 %t.coerce) #3 !dbg !20 {104entry:105  %t.i = alloca %struct.t1, align 4106  call void @llvm.dbg.declare(metadata ptr %t.i, metadata !15, metadata !16), !dbg !21107  %t = alloca %struct.t1, align 4108  %agg.tmp = alloca %struct.t1, align 4109  store i32 %t.coerce, ptr %t, align 4110  call void @llvm.dbg.declare(metadata ptr %t, metadata !23, metadata !16), !dbg !24111  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %agg.tmp, ptr align 4 %t, i64 4, i1 false), !dbg !25112  %0 = load i32, ptr %agg.tmp, align 4, !dbg !26113  store i32 %0, ptr %t.i, align 4114  call void @_Z1fv(), !dbg !27115  ret void, !dbg !28116}117 118; Function Attrs: argmemonly nounwind119declare void @llvm.memcpy.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1) #4120 121; Function Attrs: noinline uwtable122define void @_Z3bar2t1(i32 %t.coerce) #3 !dbg !29 {123entry:124  %t.i = alloca %struct.t1, align 4125  call void @llvm.dbg.declare(metadata ptr %t.i, metadata !15, metadata !16), !dbg !30126  %t = alloca %struct.t1, align 4127  %agg.tmp = alloca %struct.t1, align 4128  store i32 %t.coerce, ptr %t, align 4129  call void @llvm.dbg.declare(metadata ptr %t, metadata !32, metadata !16), !dbg !33130  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %agg.tmp, ptr align 4 %t, i64 4, i1 false), !dbg !34131  %0 = load i32, ptr %agg.tmp, align 4, !dbg !35132  store i32 %0, ptr %t.i, align 4133  call void @_Z1fv(), !dbg !36134  ret void, !dbg !37135}136 137!llvm.dbg.cu = !{!0, !3}138!llvm.ident = !{!5, !5}139!llvm.module.flags = !{!6, !7}140 141!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 302809) (llvm/trunk 302815)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: true)142!1 = !DIFile(filename: "foo.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch")143!2 = !{}144!3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !4, producer: "clang version 5.0.0 (trunk 302809) (llvm/trunk 302815)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: true)145!4 = !DIFile(filename: "bar.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch")146!5 = !{!"clang version 5.0.0 (trunk 302809) (llvm/trunk 302815)"}147!6 = !{i32 2, !"Dwarf Version", i32 4}148!7 = !{i32 2, !"Debug Info Version", i32 3}149!8 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f12t1", scope: !1, file: !1, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)150!9 = !DISubroutineType(types: !10)151!10 = !{null, !11}152!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", file: !1, line: 1, size: 32, elements: !12, identifier: "_ZTS2t1")153!12 = !{!13}154!13 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !11, file: !1, line: 1, baseType: !14, size: 32)155!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)156!15 = !DILocalVariable(name: "t", arg: 1, scope: !8, file: !1, line: 3, type: !11)157!16 = !DIExpression()158!17 = !DILocation(line: 3, column: 43, scope: !8)159!18 = !DILocation(line: 4, column: 3, scope: !8)160!19 = !DILocation(line: 5, column: 1, scope: !8)161!20 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foo2t1", scope: !1, file: !1, line: 6, type: !9, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)162!21 = !DILocation(line: 3, column: 43, scope: !8, inlinedAt: !22)163!22 = distinct !DILocation(line: 7, column: 3, scope: !20)164!23 = !DILocalVariable(name: "t", arg: 1, scope: !20, file: !1, line: 6, type: !11)165!24 = !DILocation(line: 6, column: 13, scope: !20)166!25 = !DILocation(line: 7, column: 6, scope: !20)167!26 = !DILocation(line: 7, column: 3, scope: !20)168!27 = !DILocation(line: 4, column: 3, scope: !8, inlinedAt: !22)169!28 = !DILocation(line: 8, column: 1, scope: !20)170!29 = distinct !DISubprogram(name: "bar", linkageName: "_Z3bar2t1", scope: !4, file: !4, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !3, retainedNodes: !2)171!30 = !DILocation(line: 3, column: 43, scope: !8, inlinedAt: !31)172!31 = distinct !DILocation(line: 4, column: 3, scope: !29)173!32 = !DILocalVariable(name: "t", arg: 1, scope: !29, file: !4, line: 3, type: !11)174!33 = !DILocation(line: 3, column: 13, scope: !29)175!34 = !DILocation(line: 4, column: 6, scope: !29)176!35 = !DILocation(line: 4, column: 3, scope: !29)177!36 = !DILocation(line: 4, column: 3, scope: !8, inlinedAt: !31)178!37 = !DILocation(line: 5, column: 1, scope: !29)179