1; RUN: llc -O0 %s -o - -filetype=obj \
2; RUN:   | llvm-dwarfdump -statistics - | FileCheck %s
3
4; This checks that if DW_TAG_structure_type duplicates in multiple CU,
5; the number of total vars ("source variables") will include every copy,
6; so the number of "variables with location" doesn't exceed the number of total vars.
7
8; $ cat test.h
9; struct s { static const int ss = 42; };
10;
11; $ cat test1.cpp
12; #include "test.h"
13; s S1;
14;
15; $ cat test2.cpp
16; #include "test.h"
17; s S2;
18
19; CHECK:      "#source variables": 4,
20; CHECK:      "#source variables with location": 4,
21
22source_filename = "llvm-link"
23target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
24target triple = "x86_64-unknown-linux-gnu"
25
26%struct.s = type { i8 }
27%struct.s.1 = type { i8 }
28
29@S1 = dso_local global %struct.s zeroinitializer, align 1, !dbg !0
30@S2 = dso_local global %struct.s.1 zeroinitializer, align 1, !dbg !13
31
32!llvm.dbg.cu = !{!2, !15}
33!llvm.ident = !{!18, !18}
34!llvm.module.flags = !{!19, !20, !21}
35
36!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
37!1 = distinct !DIGlobalVariable(name: "S1", scope: !2, file: !3, line: 2, type: !6, isLocal: false, isDefinition: true)
38!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 10.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !5, globals: !12, splitDebugInlining: false, nameTableKind: None)
39!3 = !DIFile(filename: "test1.cpp", directory: "/")
40!4 = !{}
41!5 = !{!6}
42!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s", file: !7, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !8, identifier: "_ZTS1s")
43!7 = !DIFile(filename: "./test.h", directory: "/")
44!8 = !{!9}
45!9 = !DIDerivedType(tag: DW_TAG_member, name: "ss", scope: !6, file: !7, line: 1, baseType: !10, flags: DIFlagStaticMember, extraData: i32 42)
46!10 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !11)
47!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
48!12 = !{!0}
49!13 = !DIGlobalVariableExpression(var: !14, expr: !DIExpression())
50!14 = distinct !DIGlobalVariable(name: "S2", scope: !15, file: !16, line: 2, type: !6, isLocal: false, isDefinition: true)
51!15 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !16, producer: "clang version 10.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !22, globals: !17, splitDebugInlining: false, nameTableKind: None)
52!16 = !DIFile(filename: "test2.cpp", directory: "/")
53!17 = !{!13}
54!18 = !{!"clang version 10.0.0"}
55!19 = !{i32 7, !"Dwarf Version", i32 4}
56!20 = !{i32 2, !"Debug Info Version", i32 3}
57!21 = !{i32 1, !"wchar_size", i32 4}
58!22 = !{!23}
59!23 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s", file: !7, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !24, identifier: "_ZTS1s")
60!24 = !{!25}
61!25 = !DIDerivedType(tag: DW_TAG_member, name: "ss", scope: !23, file: !7, line: 1, baseType: !10, flags: DIFlagStaticMember, extraData: i32 42)
62