brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.4 KiB · f8f925d Raw
153 lines · plain
1# RUN: llc -start-after=livedebugvalues --filetype=obj %s -o - \2# RUN:     | llvm-dwarfdump -v --name local* --regex - | FileCheck %s3#4# Generated with opt -sroa, llc -stop-after=livedebugvalues, with some metadata5# removed by hand:6# long a, b, c;7# long funone() {8#   unsigned localone;9#   if (c)10#     return b;11#   // Location should start here.12#   localone = 0;13#   return a;14# }15#16# short funtwo() {17#   union {18#     char b[2];19#     short c;20#   } localtwo;21#   {22#     // Location should start here.23#     memcpy(localtwo.b, 0, 2);24#   }25#   return localtwo.c;26# }27#28# Check that the local variables each have a location range which reflects the29# fact that they're both unavailable at the start of the functions.30#31# CHECK:        DW_TAG_variable [32# CHECK-NEXT:     DW_AT_location [DW_FORM_sec_offset]33# CHECK-NEXT:         [0x{{[0-9a-z]+}}, 0x{{[0-9a-z]+}})34# CHECK-NEXT:     DW_AT_name {{.*}} = "localone"35#36# CHECK:        DW_TAG_variable [37# CHECK-NEXT:     DW_AT_location [DW_FORM_sec_offset]38# CHECK-NEXT:         [0x{{[0-9a-z]+}}, 0x{{[0-9a-z]+}})39# CHECK-NEXT:     DW_AT_name {{.*}} = "localtwo"40 41--- |42  target triple = "x86_64-unknown-linux-gnu"43 44  @c = dso_local global i64 0, align 8, !dbg !045  @b = dso_local global i64 0, align 8, !dbg !946  @a = dso_local global i64 0, align 8, !dbg !647 48  define dso_local i64 @funone() !dbg !15 {49  entry:50    %0 = load i64, ptr @c, align 8, !dbg !2151    %tobool = icmp ne i64 %0, 0, !dbg !2152    br i1 %tobool, label %if.then, label %if.end, !dbg !2753 54  if.then:                                          ; preds = %entry55    %1 = load i64, ptr @b, align 8, !dbg !2156    br label %cleanup, !dbg !2157 58  if.end:                                           ; preds = %entry59    call void @llvm.dbg.value(metadata i32 0, metadata !19, metadata !DIExpression()), !dbg !2760    %2 = load i64, ptr @a, align 8, !dbg !2761    br label %cleanup, !dbg !2762 63  cleanup:                                          ; preds = %if.end, %if.then64    %retval.0 = phi i64 [ %1, %if.then ], [ %2, %if.end ], !dbg !2765    ret i64 %retval.0, !dbg !2766  }67 68  define dso_local signext i16 @funtwo() !dbg !34 {69  entry:70    %localtwo.sroa.0.0.copyload = load i16, ptr null, align 1, !dbg !4871    call void @llvm.dbg.value(metadata i16 %localtwo.sroa.0.0.copyload, metadata !39, metadata !DIExpression()), !dbg !5172    ret i16 %localtwo.sroa.0.0.copyload, !dbg !5173  }74 75  declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)76  declare void @llvm.dbg.value(metadata, metadata, metadata)77 78  !llvm.dbg.cu = !{!2}79  !llvm.module.flags = !{!11, !12, !13}80  !llvm.ident = !{!14}81 82  !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())83  !1 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)84  !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)85  !3 = !DIFile(filename: "test.c", directory: "/")86  !4 = !{}87  !5 = !{!6, !9, !0}88  !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())89  !7 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)90  !8 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)91  !9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())92  !10 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)93  !11 = !{i32 7, !"Dwarf Version", i32 4}94  !12 = !{i32 2, !"Debug Info Version", i32 3}95  !13 = !{i32 1, !"wchar_size", i32 4}96  !14 = !{!"clang version 11.0.0"}97  !15 = distinct !DISubprogram(name: "funone", scope: !3, file: !3, line: 3, type: !16, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !18)98  !16 = !DISubroutineType(types: !17)99  !17 = !{!8}100  !18 = !{!19}101  !19 = !DILocalVariable(name: "localone", scope: !15, file: !3, line: 4, type: !20)102  !20 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)103  !21 = !DILocation(line: 5, column: 7, scope: !22)104  !22 = distinct !DILexicalBlock(scope: !15, file: !3, line: 5, column: 7)105  !27 = !DILocation(line: 5, column: 7, scope: !15)106  !34 = distinct !DISubprogram(name: "funtwo", scope: !3, file: !3, line: 13, type: !35, scopeLine: 13, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !38)107  !35 = !DISubroutineType(types: !36)108  !36 = !{!37}109  !37 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)110  !38 = !{!39}111  !39 = !DILocalVariable(name: "localtwo", scope: !34, file: !3, line: 17, type: !40)112  !40 = distinct !DICompositeType(tag: DW_TAG_union_type, scope: !34, file: !3, line: 14, size: 16, elements: !41)113  !41 = !{!42, !47}114  !42 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !40, file: !3, line: 15, baseType: !43, size: 16)115  !43 = !DICompositeType(tag: DW_TAG_array_type, baseType: !44, size: 16, elements: !45)116  !44 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)117  !45 = !{!46}118  !46 = !DISubrange(count: 2)119  !47 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !40, file: !3, line: 16, baseType: !37, size: 16)120  !48 = !DILocation(line: 20, column: 5, scope: !49)121  !49 = distinct !DILexicalBlock(scope: !34, file: !3, line: 18, column: 3)122  !51 = !DILocation(line: 22, column: 3, scope: !34)123 124...125---126name:            funone127body:             |128  bb.0.entry:129    successors: %bb.1(0x50000000), %bb.2(0x30000000)130 131    CMP64mi32 $rip, 1, $noreg, @c, $noreg, 0, implicit-def $eflags, debug-location !21 :: (dereferenceable load (s64) from @c)132    JCC_1 %bb.2, 4, implicit killed $eflags, debug-location !27133 134  bb.1.if.then:135    renamable $rax = MOV64rm $rip, 1, $noreg, @b, $noreg, debug-location !21 :: (dereferenceable load (s64) from @b)136    RET64 $rax, debug-location !27137 138  bb.2.if.end:139    DBG_VALUE 0, $noreg, !19, !DIExpression(), debug-location !27140    renamable $rax = MOV64rm $rip, 1, $noreg, @a, $noreg, debug-location !27 :: (dereferenceable load (s64) from @a)141    RET64 $rax, debug-location !27142 143...144---145name:            funtwo146body:             |147  bb.0.entry:148    $eax = MOVZX32rm16 $noreg, 1, $noreg, 0, $noreg, debug-location !48 :: (load (s16) from `ptr null`, align 1)149    DBG_VALUE $ax, $noreg, !39, !DIExpression(), debug-location !51150    RET64 $ax, debug-location !51151 152...153