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 3 4; Both A and B should get forward declarations and complete definitions for this 5; example. 6 7; C++ source to regenerate: 8; $ cat t.cpp 9; struct B { int b; }; 10; struct A { B *b; }; 11; int f(A *p) { return p->b->b; } 12; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll 13 14; CHECK: CodeViewTypes [ 15; CHECK: Section: .debug$T (6) 16; CHECK: Magic: 0x4 17; CHECK: Struct (0x1000) { 18; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505) 19; CHECK: MemberCount: 0 20; CHECK: Properties [ (0x280) 21; CHECK: ForwardReference (0x80) 22; CHECK: HasUniqueName (0x200) 23; CHECK: ] 24; CHECK: FieldList: 0x0 25; CHECK: DerivedFrom: 0x0 26; CHECK: VShape: 0x0 27; CHECK: SizeOf: 0 28; CHECK: Name: A 29; CHECK: LinkageName: .?AUA@@ 30; CHECK: } 31; CHECK: Pointer (0x1001) { 32; CHECK: TypeLeafKind: LF_POINTER (0x1002) 33; CHECK: PointeeType: A (0x1000) 34; CHECK: PtrType: Near64 (0xC) 35; CHECK: PtrMode: Pointer (0x0) 36; CHECK: IsFlat: 0 37; CHECK: IsConst: 0 38; CHECK: IsVolatile: 0 39; CHECK: IsUnaligned: 0 40; CHECK: SizeOf: 8 41; CHECK: } 42; CHECK: ArgList (0x1002) { 43; CHECK: TypeLeafKind: LF_ARGLIST (0x1201) 44; CHECK: NumArgs: 1 45; CHECK: Arguments [ 46; CHECK: ArgType: A* (0x1001) 47; CHECK: ] 48; CHECK: } 49; CHECK: Procedure (0x1003) { 50; CHECK: TypeLeafKind: LF_PROCEDURE (0x1008) 51; CHECK: ReturnType: int (0x74) 52; CHECK: CallingConvention: NearC (0x0) 53; CHECK: FunctionOptions [ (0x0) 54; CHECK: ] 55; CHECK: NumParameters: 1 56; CHECK: ArgListType: (A*) (0x1002) 57; CHECK: } 58; CHECK: Struct (0x1004) { 59; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505) 60; CHECK: MemberCount: 0 61; CHECK: Properties [ (0x280) 62; CHECK: ForwardReference (0x80) 63; CHECK: HasUniqueName (0x200) 64; CHECK: ] 65; CHECK: FieldList: 0x0 66; CHECK: DerivedFrom: 0x0 67; CHECK: VShape: 0x0 68; CHECK: SizeOf: 0 69; CHECK: Name: B 70; CHECK: LinkageName: .?AUB@@ 71; CHECK: } 72; CHECK: Pointer (0x1005) { 73; CHECK: TypeLeafKind: LF_POINTER (0x1002) 74; CHECK: PointeeType: B (0x1004) 75; CHECK: PtrType: Near64 (0xC) 76; CHECK: PtrMode: Pointer (0x0) 77; CHECK: IsFlat: 0 78; CHECK: IsConst: 0 79; CHECK: IsVolatile: 0 80; CHECK: IsUnaligned: 0 81; CHECK: SizeOf: 8 82; CHECK: } 83; CHECK: FieldList (0x1006) { 84; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203) 85; CHECK: DataMember { 86; CHECK: AccessSpecifier: Public (0x3) 87; CHECK: Type: B* (0x1005) 88; CHECK: FieldOffset: 0x0 89; CHECK: Name: b 90; CHECK: } 91; CHECK: } 92; CHECK: Struct (0x1007) { 93; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505) 94; CHECK: MemberCount: 1 95; CHECK: Properties [ (0x200) 96; CHECK: HasUniqueName (0x200) 97; CHECK: ] 98; CHECK: FieldList: <field list> (0x1006) 99; CHECK: DerivedFrom: 0x0 100; CHECK: VShape: 0x0 101; CHECK: SizeOf: 8 102; CHECK: Name: A 103; CHECK: LinkageName: .?AUA@@ 104; CHECK: } 105; CHECK: StringId (0x1008) { 106; CHECK: TypeLeafKind: LF_STRING_ID (0x1605) 107; CHECK: Id: 0x0 108; CHECK: StringData: D:\src\llvm\build\t.cpp 109; CHECK: } 110; CHECK: UdtSourceLine (0x1009) { 111; CHECK: TypeLeafKind: LF_UDT_SRC_LINE (0x1606) 112; CHECK: UDT: A (0x1007) 113; CHECK: SourceFile: D:\src\llvm\build\t.cpp (0x1008) 114; CHECK: LineNumber: 2 115; CHECK: } 116; CHECK: FieldList (0x100A) { 117; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203) 118; CHECK: DataMember { 119; CHECK: AccessSpecifier: Public (0x3) 120; CHECK: Type: int (0x74) 121; CHECK: FieldOffset: 0x0 122; CHECK: Name: b 123; CHECK: } 124; CHECK: } 125; CHECK: Struct (0x100B) { 126; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505) 127; CHECK: MemberCount: 1 128; CHECK: Properties [ (0x200) 129; CHECK: HasUniqueName (0x200) 130; CHECK: ] 131; CHECK: FieldList: <field list> (0x100A) 132; CHECK: DerivedFrom: 0x0 133; CHECK: VShape: 0x0 134; CHECK: SizeOf: 4 135; CHECK: Name: B 136; CHECK: LinkageName: .?AUB@@ 137; CHECK: } 138; CHECK: UdtSourceLine (0x100C) { 139; CHECK: TypeLeafKind: LF_UDT_SRC_LINE (0x1606) 140; CHECK: UDT: B (0x100B) 141; CHECK: SourceFile: D:\src\llvm\build\t.cpp (0x1008) 142; CHECK: LineNumber: 1 143; CHECK: } 144; CHECK: FuncId (0x100D) { 145; CHECK: TypeLeafKind: LF_FUNC_ID (0x1601) 146; CHECK: ParentScope: 0x0 147; CHECK: FunctionType: int (A*) (0x1003) 148; CHECK: Name: f 149; CHECK: } 150; CHECK: ] 151 152; ModuleID = 't.cpp' 153source_filename = "t.cpp" 154target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" 155target triple = "x86_64-pc-windows-msvc19.0.23918" 156 157%struct.A = type { ptr } 158%struct.B = type { i32 } 159 160; Function Attrs: nounwind uwtable 161define i32 @"\01?f@@YAHPEAUA@@@Z"(ptr %p) #0 !dbg !7 { 162entry: 163 %p.addr = alloca ptr, align 8 164 store ptr %p, ptr %p.addr, align 8 165 call void @llvm.dbg.declare(metadata ptr %p.addr, metadata !19, metadata !20), !dbg !21 166 %0 = load ptr, ptr %p.addr, align 8, !dbg !22 167 %1 = load ptr, ptr %0, align 8, !dbg !23 168 %2 = load i32, ptr %1, align 4, !dbg !24 169 ret i32 %2, !dbg !25 170} 171 172; Function Attrs: nounwind readnone 173declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 174 175attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "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" } 176attributes #1 = { nounwind readnone } 177 178!llvm.dbg.cu = !{!0} 179!llvm.module.flags = !{!3, !4, !5} 180!llvm.ident = !{!6} 181 182!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) 183!1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild") 184!2 = !{} 185!3 = !{i32 2, !"CodeView", i32 1} 186!4 = !{i32 2, !"Debug Info Version", i32 3} 187!5 = !{i32 1, !"PIC Level", i32 2} 188!6 = !{!"clang version 3.9.0 "} 189!7 = distinct !DISubprogram(name: "f", linkageName: "\01?f@@YAHPEAUA@@@Z", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 190!8 = !DISubroutineType(types: !9) 191!9 = !{!10, !11} 192!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 193!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64, align: 64) 194!12 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !1, line: 2, size: 64, align: 64, elements: !13, identifier: ".?AUA@@") 195!13 = !{!14} 196!14 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !12, file: !1, line: 2, baseType: !15, size: 64, align: 64) 197!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64, align: 64) 198!16 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "B", file: !1, line: 1, size: 32, align: 32, elements: !17, identifier: ".?AUB@@") 199!17 = !{!18} 200!18 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !16, file: !1, line: 1, baseType: !10, size: 32, align: 32) 201!19 = !DILocalVariable(name: "p", arg: 1, scope: !7, file: !1, line: 3, type: !11) 202!20 = !DIExpression() 203!21 = !DILocation(line: 3, column: 10, scope: !7) 204!22 = !DILocation(line: 3, column: 22, scope: !7) 205!23 = !DILocation(line: 3, column: 25, scope: !7) 206!24 = !DILocation(line: 3, column: 28, scope: !7) 207!25 = !DILocation(line: 3, column: 15, scope: !7) 208