• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -filetype=obj > %t.obj
2; RUN: llvm-readobj -codeview %t.obj | FileCheck --check-prefix=READOBJ %s
3; RUN: llvm-pdbutil dump -symbols %t.obj | FileCheck --check-prefix=PDBUTIL %s
4
5; C++ to regenerate:
6; $ clang -g -gcodeview -m64 -S -emit-llvm t.cpp
7; $ cat t.cpp
8; void f() {
9;   typedef int FOO;
10;   FOO f;
11; }
12;
13; struct S { int x; };
14; float g(S *s) {
15;   union pun { int x; float f; } p;
16;   p.x = s->x;
17;   return p.f;
18; }
19; struct A {
20;   // We should not output S_UDT for nested typedef.
21;   typedef S C;
22;   C c;
23;   // We should output S_UDT for typedef of nested unnamed struct
24;   typedef struct { long X; } D;
25;   D d;
26; };
27; A a;
28;
29; typedef struct { int x; } U;
30; U u;
31
32; READOBJ-NOT:  UDTName: A::C
33; READOBJ:      {{.*}}Proc{{.*}}Sym {
34; READOBJ:        DisplayName: f
35; READOBJ:        LinkageName: ?f@@YAXXZ
36; READOBJ:      }
37; READOBJ:      UDTSym {
38; READOBJ-NEXT:   Kind: S_UDT (0x1108)
39; READOBJ-NEXT:   Type: int (0x74)
40; READOBJ-NEXT:   UDTName: f::FOO
41; READOBJ-NEXT: }
42; READOBJ-NEXT: ProcEnd {
43
44; READOBJ:      {{.*}}Proc{{.*}}Sym {
45; READOBJ:        DisplayName: g
46; READOBJ:        LinkageName: ?g@@YAMPEAUS@@@Z
47; READOBJ:      }
48; READOBJ:      UDTSym {
49; READOBJ-NEXT:   Kind: S_UDT (0x1108)
50; READOBJ-NEXT:   Type: g::pun (0x{{[0-9A-F]+}})
51; READOBJ-NEXT:   UDTName: g::pun
52; READOBJ-NEXT: }
53; READOBJ-NEXT: ProcEnd {
54
55; READOBJ:      Subsection
56; READOBJ-NOT:  {{.*}}Proc{{.*}}Sym
57; READOBJ:      UDTSym {
58; READOBJ-NEXT:   Kind: S_UDT (0x1108)
59; READOBJ-NEXT: Type: S (0x{{[0-9A-F]+}})
60; READOBJ-NEXT: UDTName: S
61; READOBJ:      UDTSym {
62; READOBJ-NEXT:   Kind: S_UDT (0x1108)
63; READOBJ-NEXT: Type: A (0x{{[0-9A-F]+}})
64; READOBJ-NEXT: UDTName: A
65; READOBJ:      UDTSym {
66; READOBJ-NEXT:   Kind: S_UDT (0x1108)
67; READOBJ-NEXT: Type: A::D (0x{{[0-9A-F]+}})
68; READOBJ-NEXT: UDTName: A::D
69; READOBJ:      UDTSym {
70; READOBJ-NEXT:   Kind: S_UDT (0x1108)
71; READOBJ-NEXT: Type: U (0x{{[0-9A-F]+}})
72; READOBJ-NEXT: UDTName: U
73; READOBJ:      UDTSym {
74; READOBJ-NEXT:   Kind: S_UDT (0x1108)
75; READOBJ-NEXT: Type: U (0x{{[0-9A-F]+}})
76; READOBJ-NEXT: UDTName: U
77; READOBJ-NOT: UDTSym
78
79; PDBUTIL:                           Symbols
80; PDBUTIL-NEXT: ============================================================
81; PDBUTIL-NOT:   S_UDT {{.*}} `A::C`
82; PDBUTIL:       S_UDT [size = 15] `f::FOO`
83; PDBUTIL:       S_UDT [size = 15] `g::pun`
84; PDBUTIL:       S_UDT [size = 10] `S`
85; PDBUTIL:       S_UDT [size = 10] `A`
86; PDBUTIL:       S_UDT [size = 13] `A::D`
87; PDBUTIL:       S_UDT [size = 10] `U`
88; PDBUTIL:       S_UDT [size = 10] `U`
89
90source_filename = "test/DebugInfo/COFF/udts.ll"
91target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
92target triple = "x86_64-pc-windows-msvc19.11.25506"
93
94%struct.A = type { %struct.S, %"struct.A::D" }
95%struct.S = type { i32 }
96%"struct.A::D" = type { i32 }
97%struct.U = type { i32 }
98%union.pun = type { i32 }
99
100@"\01?a@@3UA@@A" = global %struct.A zeroinitializer, align 4, !dbg !0
101@"\01?u@@3UU@@A" = global %struct.U zeroinitializer, align 4, !dbg !6
102
103; Function Attrs: noinline nounwind optnone uwtable
104define void @"\01?f@@YAXXZ"() #0 !dbg !31 {
105  %1 = alloca i32, align 4
106  call void @llvm.dbg.declare(metadata i32* %1, metadata !34, metadata !DIExpression()), !dbg !36
107  ret void, !dbg !37
108}
109
110; Function Attrs: nounwind readnone speculatable
111declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
112
113; Function Attrs: noinline nounwind optnone uwtable
114define float @"\01?g@@YAMPEAUS@@@Z"(%struct.S*) #0 !dbg !38 {
115  %2 = alloca %struct.S*, align 8
116  %3 = alloca %union.pun, align 4
117  store %struct.S* %0, %struct.S** %2, align 8
118  call void @llvm.dbg.declare(metadata %struct.S** %2, metadata !43, metadata !DIExpression()), !dbg !44
119  call void @llvm.dbg.declare(metadata %union.pun* %3, metadata !45, metadata !DIExpression()), !dbg !50
120  %4 = load %struct.S*, %struct.S** %2, align 8, !dbg !51
121  %5 = getelementptr inbounds %struct.S, %struct.S* %4, i32 0, i32 0, !dbg !52
122  %6 = load i32, i32* %5, align 4, !dbg !52
123  %7 = bitcast %union.pun* %3 to i32*, !dbg !53
124  store i32 %6, i32* %7, align 4, !dbg !54
125  %8 = bitcast %union.pun* %3 to float*, !dbg !55
126  %9 = load float, float* %8, align 4, !dbg !55
127  ret float %9, !dbg !56
128}
129
130attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
131attributes #1 = { nounwind readnone speculatable }
132
133!llvm.dbg.cu = !{!2}
134!llvm.module.flags = !{!26, !27, !28, !29}
135!llvm.ident = !{!30}
136
137!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
138!1 = distinct !DIGlobalVariable(name: "a", linkageName: "\01?a@@3UA@@A", scope: !2, file: !3, line: 21, type: !13, isLocal: false, isDefinition: true)
139!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 6.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
140!3 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvmbuild\5Cninja-release", checksumkind: CSK_MD5, checksum: "e894de94ed2e0d503ebb5dbcc550c544")
141!4 = !{}
142!5 = !{!0, !6}
143!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
144!7 = distinct !DIGlobalVariable(name: "u", linkageName: "\01?u@@3UU@@A", scope: !2, file: !3, line: 24, type: !8, isLocal: false, isDefinition: true)
145!8 = !DIDerivedType(tag: DW_TAG_typedef, name: "U", file: !3, line: 23, baseType: !9)
146!9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "U", file: !3, line: 23, size: 32, elements: !10, identifier: ".?AUU@@")
147!10 = !{!11}
148!11 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !9, file: !3, line: 23, baseType: !12, size: 32)
149!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
150!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !3, line: 13, size: 64, elements: !14, identifier: ".?AUA@@")
151!14 = !{!15, !19, !20, !24, !25}
152!15 = !DIDerivedType(tag: DW_TAG_typedef, name: "C", scope: !13, file: !3, line: 15, baseType: !16)
153!16 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !3, line: 6, size: 32, elements: !17, identifier: ".?AUS@@")
154!17 = !{!18}
155!18 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !16, file: !3, line: 6, baseType: !12, size: 32)
156!19 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !13, file: !3, line: 16, baseType: !15, size: 32)
157!20 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "D", scope: !13, file: !3, line: 18, size: 32, elements: !21, identifier: ".?AUD@A@@")
158!21 = !{!22}
159!22 = !DIDerivedType(tag: DW_TAG_member, name: "X", scope: !20, file: !3, line: 18, baseType: !23, size: 32)
160!23 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed)
161!24 = !DIDerivedType(tag: DW_TAG_typedef, name: "D", scope: !13, file: !3, line: 18, baseType: !20)
162!25 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !13, file: !3, line: 19, baseType: !24, size: 32, offset: 32)
163!26 = !{i32 2, !"CodeView", i32 1}
164!27 = !{i32 2, !"Debug Info Version", i32 3}
165!28 = !{i32 1, !"wchar_size", i32 2}
166!29 = !{i32 7, !"PIC Level", i32 2}
167!30 = !{!"clang version 6.0.0 "}
168!31 = distinct !DISubprogram(name: "f", linkageName: "\01?f@@YAXXZ", scope: !3, file: !3, line: 1, type: !32, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4)
169!32 = !DISubroutineType(types: !33)
170!33 = !{null}
171!34 = !DILocalVariable(name: "f", scope: !31, file: !3, line: 3, type: !35)
172!35 = !DIDerivedType(tag: DW_TAG_typedef, name: "FOO", scope: !31, file: !3, line: 2, baseType: !12)
173!36 = !DILocation(line: 3, column: 7, scope: !31)
174!37 = !DILocation(line: 4, column: 1, scope: !31)
175!38 = distinct !DISubprogram(name: "g", linkageName: "\01?g@@YAMPEAUS@@@Z", scope: !3, file: !3, line: 7, type: !39, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4)
176!39 = !DISubroutineType(types: !40)
177!40 = !{!41, !42}
178!41 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
179!42 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64)
180!43 = !DILocalVariable(name: "s", arg: 1, scope: !38, file: !3, line: 7, type: !42)
181!44 = !DILocation(line: 7, column: 12, scope: !38)
182!45 = !DILocalVariable(name: "p", scope: !38, file: !3, line: 8, type: !46)
183!46 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "pun", scope: !38, file: !3, line: 8, size: 32, elements: !47)
184!47 = !{!48, !49}
185!48 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !46, file: !3, line: 8, baseType: !12, size: 32)
186!49 = !DIDerivedType(tag: DW_TAG_member, name: "f", scope: !46, file: !3, line: 8, baseType: !41, size: 32)
187!50 = !DILocation(line: 8, column: 33, scope: !38)
188!51 = !DILocation(line: 9, column: 9, scope: !38)
189!52 = !DILocation(line: 9, column: 12, scope: !38)
190!53 = !DILocation(line: 9, column: 5, scope: !38)
191!54 = !DILocation(line: 9, column: 7, scope: !38)
192!55 = !DILocation(line: 10, column: 12, scope: !38)
193!56 = !DILocation(line: 10, column: 3, scope: !38)