1 ; RUN: llc -mtriple=x86_64-apple-darwin %s -o - -filetype=obj | \
2 ; RUN: llvm-dwarfdump -v --debug-info - | FileCheck %s
4 ; Test emitting debug info for fragmented global values.
5 ; This is a handcrafted example of an SROAed global variable.
6 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
7 target triple = "x86_64-apple-macosx10.12.0"
9 %struct.anon = type { i32, i32 }
11 ; CHECK: DW_TAG_variable
12 ; CHECK-NEXT: DW_AT_name {{.*}}"point"
14 ; CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x4, DW_OP_piece 0x4, DW_OP_addr 0x0, DW_OP_piece 0x4)
17 ; CHECK: DW_TAG_variable
18 ; CHECK-NEXT: DW_AT_name {{.*}}"part_const"
20 ; CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x8, DW_OP_piece 0x4, DW_OP_lit2, DW_OP_stack_value, DW_OP_piece 0x4)
21 ; [0x0000000000000008], piece 0x00000004, constu 0x00000002, stack-value, piece 0x00000004
23 ; CHECK: DW_TAG_variable
24 ; CHECK-NEXT: DW_AT_name {{.*}}"full_const"
26 ; CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_lit1, DW_OP_stack_value, DW_OP_piece 0x4, DW_OP_lit2, DW_OP_stack_value, DW_OP_piece 0x4)
28 @point.y = global i32 2, align 4, !dbg !13
29 @point.x = global i32 1, align 4, !dbg !12
31 @part_const.x = global i32 1, align 4, !dbg !14
34 !llvm.module.flags = !{!10, !11}
36 !0 = distinct !DIGlobalVariable(name: "point", scope: !1, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true)
37 !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4)
38 !2 = !DIFile(filename: "g.c", directory: "/")
40 !4 = !{!12, !13, !14, !15, !17, !18, !20}
41 !5 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !2, line: 1, size: 64, elements: !6)
43 !7 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !5, file: !2, line: 1, baseType: !8, size: 32)
44 !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
45 !9 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !5, file: !2, line: 1, baseType: !8, size: 32, offset: 32)
46 !10 = !{i32 2, !"Dwarf Version", i32 4}
47 !11 = !{i32 2, !"Debug Info Version", i32 3}
48 !12 = !DIGlobalVariableExpression(var: !0, expr: !DIExpression(DW_OP_LLVM_fragment, 0, 32))
49 !13 = !DIGlobalVariableExpression(var: !0, expr: !DIExpression(DW_OP_LLVM_fragment, 32, 32))
50 !14 = !DIGlobalVariableExpression(var: !16, expr: !DIExpression(DW_OP_LLVM_fragment, 0, 32))
51 !15 = !DIGlobalVariableExpression(var: !16, expr: !DIExpression(DW_OP_constu, 2,
52 DW_OP_stack_value, DW_OP_LLVM_fragment, 32, 32))
53 !16 = distinct !DIGlobalVariable(name: "part_const", scope: !1, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true)
54 !17 = !DIGlobalVariableExpression(var: !19, expr: !DIExpression(DW_OP_constu, 1,
55 DW_OP_stack_value, DW_OP_LLVM_fragment, 0, 32))
56 !18 = !DIGlobalVariableExpression(var: !19, expr: !DIExpression(DW_OP_constu, 2,
57 DW_OP_stack_value, DW_OP_LLVM_fragment, 32, 32))
58 !19 = distinct !DIGlobalVariable(name: "full_const", scope: !1, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true)
59 !20 = !DIGlobalVariableExpression(var: !0, expr: !DIExpression())