1 ; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s
2 ; RUN: llc < %s | llvm-mc -filetype=obj --triple=x86_64-windows | llvm-readobj - --codeview | FileCheck %s
4 ; This test ensures that circular type references through pointer types don't
5 ; cause infinite recursion. It also tests that we always refer to the forward
6 ; declaration type index in field lists and pointer types, which is consistent
7 ; with what MSVC does. It ensures that these records get merged when merging
8 ; streams even if the complete record types differ slightly due to ODR
9 ; violations, i.e. methods that only exist ifndef NDEBUG.
11 ; C++ source to regenerate:
20 ; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
22 ; CHECK: CodeViewTypes [
23 ; CHECK: Section: .debug$T (6)
25 ; CHECK: ArgList (0x1000) {
26 ; CHECK: TypeLeafKind: LF_ARGLIST (0x1201)
31 ; CHECK: Procedure (0x1001) {
32 ; CHECK: TypeLeafKind: LF_PROCEDURE (0x1008)
33 ; CHECK: ReturnType: void (0x3)
34 ; CHECK: CallingConvention: NearC (0x0)
35 ; CHECK: FunctionOptions [ (0x0)
37 ; CHECK: NumParameters: 0
38 ; CHECK: ArgListType: () (0x1000)
40 ; CHECK: FuncId (0x1002) {
41 ; CHECK: TypeLeafKind: LF_FUNC_ID (0x1601)
42 ; CHECK: ParentScope: 0x0
43 ; CHECK: FunctionType: void () (0x1001)
46 ; CHECK: Struct (0x1003) {
47 ; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
48 ; CHECK: MemberCount: 0
49 ; CHECK: Properties [ (0x80)
50 ; CHECK: ForwardReference (0x80)
52 ; CHECK: FieldList: 0x0
53 ; CHECK: DerivedFrom: 0x0
58 ; CHECK: Struct (0x1004) {
59 ; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
60 ; CHECK: MemberCount: 0
61 ; CHECK: Properties [ (0x80)
62 ; CHECK: ForwardReference (0x80)
64 ; CHECK: FieldList: 0x0
65 ; CHECK: DerivedFrom: 0x0
70 ; CHECK: Pointer (0x1005) {
71 ; CHECK: TypeLeafKind: LF_POINTER (0x1002)
72 ; CHECK: PointeeType: B (0x1004)
73 ; CHECK: PtrType: Near64 (0xC)
74 ; CHECK: PtrMode: Pointer (0x0)
77 ; CHECK: IsVolatile: 0
78 ; CHECK: IsUnaligned: 0
80 ; CHECK: FieldList (0x1006) {
81 ; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
83 ; CHECK: AccessSpecifier: Public (0x3)
84 ; CHECK: Type: B* (0x1005)
85 ; CHECK: FieldOffset: 0x0
89 ; CHECK: Struct (0x1007) {
90 ; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
91 ; CHECK: MemberCount: 1
92 ; CHECK: Properties [ (0x0)
94 ; CHECK: FieldList: <field list> (0x1006)
95 ; CHECK: DerivedFrom: 0x0
100 ; CHECK: StringId (0x1008) {
101 ; CHECK: TypeLeafKind: LF_STRING_ID (0x1605)
103 ; CHECK: StringData: D:\src\llvm\build\t.cpp
105 ; CHECK: UdtSourceLine (0x1009) {
106 ; CHECK: TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
107 ; CHECK: UDT: A (0x1007)
108 ; CHECK: SourceFile: D:\src\llvm\build\t.cpp (0x1008)
109 ; CHECK: LineNumber: 2
111 ; CHECK: FieldList (0x100A) {
112 ; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
113 ; CHECK: DataMember {
114 ; CHECK: AccessSpecifier: Public (0x3)
115 ; CHECK: Type: A (0x1003)
116 ; CHECK: FieldOffset: 0x0
120 ; CHECK: Struct (0x100B) {
121 ; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
122 ; CHECK: MemberCount: 1
123 ; CHECK: Properties [ (0x0)
125 ; CHECK: FieldList: <field list> (0x100A)
126 ; CHECK: DerivedFrom: 0x0
131 ; CHECK: UdtSourceLine (0x100C) {
132 ; CHECK: TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
133 ; CHECK: UDT: B (0x100B)
134 ; CHECK: SourceFile: D:\src\llvm\build\t.cpp (0x1008)
135 ; CHECK: LineNumber: 3
140 source_filename = "t.cpp"
141 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
142 target triple = "x86_64-pc-windows-msvc19.0.23918"
144 %struct.A = type { %struct.B* }
145 %struct.B = type { %struct.A }
147 ; Function Attrs: nounwind uwtable
148 define void @"\01?f@@YAXXZ"() #0 !dbg !7 {
150 %a = alloca %struct.A, align 8
151 %b = alloca %struct.B, align 8
152 call void @llvm.dbg.declare(metadata %struct.A* %a, metadata !10, metadata !18), !dbg !19
153 call void @llvm.dbg.declare(metadata %struct.B* %b, metadata !20, metadata !18), !dbg !21
157 ; Function Attrs: nounwind readnone
158 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
160 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" }
161 attributes #1 = { nounwind readnone }
164 !llvm.module.flags = !{!3, !4, !5}
167 !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)
168 !1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
170 !3 = !{i32 2, !"CodeView", i32 1}
171 !4 = !{i32 2, !"Debug Info Version", i32 3}
172 !5 = !{i32 1, !"PIC Level", i32 2}
173 !6 = !{!"clang version 3.9.0 "}
174 !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)
175 !8 = !DISubroutineType(types: !9)
177 !10 = !DILocalVariable(name: "a", scope: !7, file: !1, line: 5, type: !11)
178 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !1, line: 2, size: 64, align: 64, elements: !12)
180 !13 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !11, file: !1, line: 2, baseType: !14, size: 64, align: 64)
181 !14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 64, align: 64)
182 !15 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "B", file: !1, line: 3, size: 64, align: 64, elements: !16)
184 !17 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !15, file: !1, line: 3, baseType: !11, size: 64, align: 64)
185 !18 = !DIExpression()
186 !19 = !DILocation(line: 5, column: 5, scope: !7)
187 !20 = !DILocalVariable(name: "b", scope: !7, file: !1, line: 6, type: !15)
188 !21 = !DILocation(line: 6, column: 5, scope: !7)
189 !22 = !DILocation(line: 7, column: 1, scope: !7)