1 ; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s
3 ; This test ensures that circular type references through pointer types don't
4 ; cause infinite recursion. It also tests that we always refer to the forward
5 ; declaration type index in field lists and pointer types, which is consistent
6 ; with what MSVC does. It ensures that these records get merged when merging
7 ; streams even if the complete record types differ slightly due to ODR
8 ; violations, i.e. methods that only exist ifndef NDEBUG.
10 ; C++ source to regenerate:
19 ; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
21 ; CHECK: CodeViewTypes [
22 ; CHECK: Section: .debug$T (6)
24 ; CHECK: ArgList (0x1000) {
25 ; CHECK: TypeLeafKind: LF_ARGLIST (0x1201)
30 ; CHECK: Procedure (0x1001) {
31 ; CHECK: TypeLeafKind: LF_PROCEDURE (0x1008)
32 ; CHECK: ReturnType: void (0x3)
33 ; CHECK: CallingConvention: NearC (0x0)
34 ; CHECK: FunctionOptions [ (0x0)
36 ; CHECK: NumParameters: 0
37 ; CHECK: ArgListType: () (0x1000)
39 ; CHECK: FuncId (0x1002) {
40 ; CHECK: TypeLeafKind: LF_FUNC_ID (0x1601)
41 ; CHECK: ParentScope: 0x0
42 ; CHECK: FunctionType: void () (0x1001)
45 ; CHECK: Struct (0x1003) {
46 ; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
47 ; CHECK: MemberCount: 0
48 ; CHECK: Properties [ (0x80)
49 ; CHECK: ForwardReference (0x80)
51 ; CHECK: FieldList: 0x0
52 ; CHECK: DerivedFrom: 0x0
57 ; CHECK: Struct (0x1004) {
58 ; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
59 ; CHECK: MemberCount: 0
60 ; CHECK: Properties [ (0x80)
61 ; CHECK: ForwardReference (0x80)
63 ; CHECK: FieldList: 0x0
64 ; CHECK: DerivedFrom: 0x0
69 ; CHECK: Pointer (0x1005) {
70 ; CHECK: TypeLeafKind: LF_POINTER (0x1002)
71 ; CHECK: PointeeType: B (0x1004)
72 ; CHECK: PtrType: Near64 (0xC)
73 ; CHECK: PtrMode: Pointer (0x0)
76 ; CHECK: IsVolatile: 0
77 ; CHECK: IsUnaligned: 0
79 ; CHECK: FieldList (0x1006) {
80 ; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
82 ; CHECK: AccessSpecifier: Public (0x3)
83 ; CHECK: Type: B* (0x1005)
84 ; CHECK: FieldOffset: 0x0
88 ; CHECK: Struct (0x1007) {
89 ; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
90 ; CHECK: MemberCount: 1
91 ; CHECK: Properties [ (0x0)
93 ; CHECK: FieldList: <field list> (0x1006)
94 ; CHECK: DerivedFrom: 0x0
99 ; CHECK: StringId (0x1008) {
100 ; CHECK: TypeLeafKind: LF_STRING_ID (0x1605)
102 ; CHECK: StringData: D:\src\llvm\build\t.cpp
104 ; CHECK: UdtSourceLine (0x1009) {
105 ; CHECK: TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
106 ; CHECK: UDT: A (0x1007)
107 ; CHECK: SourceFile: D:\src\llvm\build\t.cpp (0x1008)
108 ; CHECK: LineNumber: 2
110 ; CHECK: FieldList (0x100A) {
111 ; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
112 ; CHECK: DataMember {
113 ; CHECK: AccessSpecifier: Public (0x3)
114 ; CHECK: Type: A (0x1003)
115 ; CHECK: FieldOffset: 0x0
119 ; CHECK: Struct (0x100B) {
120 ; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
121 ; CHECK: MemberCount: 1
122 ; CHECK: Properties [ (0x0)
124 ; CHECK: FieldList: <field list> (0x100A)
125 ; CHECK: DerivedFrom: 0x0
130 ; CHECK: UdtSourceLine (0x100C) {
131 ; CHECK: TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
132 ; CHECK: UDT: B (0x100B)
133 ; CHECK: SourceFile: D:\src\llvm\build\t.cpp (0x1008)
134 ; CHECK: LineNumber: 3
139 source_filename = "t.cpp"
140 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
141 target triple = "x86_64-pc-windows-msvc19.0.23918"
143 %struct.A = type { %struct.B* }
144 %struct.B = type { %struct.A }
146 ; Function Attrs: nounwind uwtable
147 define void @"\01?f@@YAXXZ"() #0 !dbg !7 {
149 %a = alloca %struct.A, align 8
150 %b = alloca %struct.B, align 8
151 call void @llvm.dbg.declare(metadata %struct.A* %a, metadata !10, metadata !18), !dbg !19
152 call void @llvm.dbg.declare(metadata %struct.B* %b, metadata !20, metadata !18), !dbg !21
156 ; Function Attrs: nounwind readnone
157 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
159 attributes #0 = { nounwind uwtable "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" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
160 attributes #1 = { nounwind readnone }
163 !llvm.module.flags = !{!3, !4, !5}
166 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
167 !1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
169 !3 = !{i32 2, !"CodeView", i32 1}
170 !4 = !{i32 2, !"Debug Info Version", i32 3}
171 !5 = !{i32 1, !"PIC Level", i32 2}
172 !6 = !{!"clang version 3.9.0 "}
173 !7 = distinct !DISubprogram(name: "f", linkageName: "\01?f@@YAXXZ", scope: !1, file: !1, line: 4, type: !8, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
174 !8 = !DISubroutineType(types: !9)
176 !10 = !DILocalVariable(name: "a", scope: !7, file: !1, line: 5, type: !11)
177 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !1, line: 2, size: 64, align: 64, elements: !12)
179 !13 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !11, file: !1, line: 2, baseType: !14, size: 64, align: 64)
180 !14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 64, align: 64)
181 !15 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "B", file: !1, line: 3, size: 64, align: 64, elements: !16)
183 !17 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !15, file: !1, line: 3, baseType: !11, size: 64, align: 64)
184 !18 = !DIExpression()
185 !19 = !DILocation(line: 5, column: 5, scope: !7)
186 !20 = !DILocalVariable(name: "b", scope: !7, file: !1, line: 6, type: !15)
187 !21 = !DILocation(line: 6, column: 5, scope: !7)
188 !22 = !DILocation(line: 7, column: 1, scope: !7)