1; RUN: llc < %s -filetype=obj -o - | llvm-readobj - -codeview | FileCheck %s 2 3; C++ source to regenerate: 4; $ cat t.cpp 5; struct A { int a; }; 6; struct B : virtual A { int b; virtual int get() { return b; } }; 7; struct C : virtual A { int c; virtual int get() { return c; } }; 8; struct D : B, C { 9; virtual void f(); // make vbptr not offset zero 10; int d; 11; }; 12; D d; 13; $ clang -fno-rtti -g -gcodeview t.cpp -emit-llvm -S -o t.ll -O1 14 15; struct B's field list comes first. 16; CHECK: FieldList ({{.*}}) { 17; CHECK-NEXT: TypeLeafKind: LF_FIELDLIST (0x1203) 18; CHECK-NEXT: VirtualBaseClass { 19; CHECK-NEXT: TypeLeafKind: LF_VBCLASS (0x1401) 20; CHECK-NEXT: AccessSpecifier: Public (0x3) 21; CHECK-NEXT: BaseType: A ({{.*}}) 22; CHECK-NEXT: VBPtrType: const int* ({{.*}}) 23; CHECK-NEXT: VBPtrOffset: 0x8 24; CHECK-NEXT: VBTableIndex: 0x1 25; CHECK-NEXT: } 26; CHECK: } 27 28; struct A's field list comes next. 29; CHECK: FieldList ({{.*}}) 30; CHECK-NEXT: TypeLeafKind: LF_FIELDLIST (0x1203) 31; CHECK: } 32 33; struct C's field list comes next. 34; CHECK: FieldList ({{.*}}) 35; CHECK-NEXT: TypeLeafKind: LF_FIELDLIST (0x1203) 36; CHECK-NEXT: VirtualBaseClass { 37; CHECK-NEXT: TypeLeafKind: LF_VBCLASS (0x1401) 38; CHECK-NEXT: AccessSpecifier: Public (0x3) 39; CHECK-NEXT: BaseType: A ({{.*}}) 40; CHECK-NEXT: VBPtrType: const int* ({{.*}}) 41; CHECK-NEXT: VBPtrOffset: 0x8 42; CHECK-NEXT: VBTableIndex: 0x1 43; CHECK-NEXT: } 44; CHECK: } 45 46; struct D's field list is last. 47; CHECK: FieldList ({{.*}}) { 48; CHECK-NEXT: TypeLeafKind: LF_FIELDLIST (0x1203) 49; CHECK-NEXT: BaseClass { 50; CHECK-NEXT: TypeLeafKind: LF_BCLASS (0x1400) 51; CHECK-NEXT: AccessSpecifier: Public (0x3) 52; CHECK-NEXT: BaseType: B ({{.*}}) 53; CHECK-NEXT: BaseOffset: 0x0 54; CHECK-NEXT: } 55; CHECK-NEXT: BaseClass { 56; CHECK-NEXT: TypeLeafKind: LF_BCLASS (0x1400) 57; CHECK-NEXT: AccessSpecifier: Public (0x3) 58; CHECK-NEXT: BaseType: C ({{.*}}) 59; CHECK-NEXT: BaseOffset: 0x18 60; CHECK-NEXT: } 61; CHECK-NEXT: IndirectVirtualBaseClass { 62; CHECK-NEXT: TypeLeafKind: LF_IVBCLASS (0x1402) 63; CHECK-NEXT: AccessSpecifier: Public (0x3) 64; CHECK-NEXT: BaseType: A ({{.*}}) 65; CHECK-NEXT: VBPtrType: const int* ({{.*}}) 66; CHECK-NEXT: VBPtrOffset: 0x8 67; CHECK-NEXT: VBTableIndex: 0x1 68; CHECK-NEXT: } 69; CHECK: } 70 71; ModuleID = 't.cpp' 72source_filename = "t.cpp" 73target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" 74target triple = "x86_64-pc-windows-msvc19.12.25835" 75 76%struct.D = type { %struct.B.base, %struct.C.base, i32, [4 x i8], %struct.A } 77%struct.B.base = type { i32 (...)**, i32*, i32 } 78%struct.C.base = type { i32 (...)**, i32*, i32 } 79%struct.A = type { i32 } 80%struct.B = type { i32 (...)**, i32*, i32, [4 x i8], %struct.A } 81%struct.C = type { i32 (...)**, i32*, i32, [4 x i8], %struct.A } 82 83$"?get@B@@UEAAHXZ" = comdat any 84 85$"?get@C@@UEAAHXZ" = comdat any 86 87$"??_8D@@7BB@@@" = comdat any 88 89$"??_8D@@7BC@@@" = comdat any 90 91$"??_7D@@6BB@@@" = comdat any 92 93$"??_7D@@6BC@@@" = comdat any 94 95@"?d@@3UD@@A" = dso_local local_unnamed_addr global %struct.D { %struct.B.base { i32 (...)** bitcast ({ [2 x i8*] }* @"??_7D@@6BB@@@" to i32 (...)**), i32* getelementptr inbounds ([2 x i32], [2 x i32]* @"??_8D@@7BB@@@", i32 0, i32 0), i32 0 }, %struct.C.base { i32 (...)** bitcast ({ [1 x i8*] }* @"??_7D@@6BC@@@" to i32 (...)**), i32* getelementptr inbounds ([2 x i32], [2 x i32]* @"??_8D@@7BC@@@", i32 0, i32 0), i32 0 }, i32 0, [4 x i8] zeroinitializer, %struct.A zeroinitializer }, align 8, !dbg !0 96@"??_8D@@7BB@@@" = linkonce_odr unnamed_addr constant [2 x i32] [i32 -8, i32 48], comdat 97@"??_8D@@7BC@@@" = linkonce_odr unnamed_addr constant [2 x i32] [i32 -8, i32 24], comdat 98@"??_7D@@6BB@@@" = linkonce_odr unnamed_addr constant { [2 x i8*] } { [2 x i8*] [i8* bitcast (i32 (%struct.B*)* @"?get@B@@UEAAHXZ" to i8*), i8* bitcast (void (%struct.D*)* @"?f@D@@UEAAXXZ" to i8*)] }, comdat 99@"??_7D@@6BC@@@" = linkonce_odr unnamed_addr constant { [1 x i8*] } { [1 x i8*] [i8* bitcast (i32 (%struct.C*)* @"?get@C@@UEAAHXZ" to i8*)] }, comdat 100@llvm.global_ctors = appending global [0 x { i32, void ()*, i8* }] zeroinitializer 101 102; Function Attrs: nounwind uwtable 103define linkonce_odr dso_local i32 @"?get@B@@UEAAHXZ"(%struct.B* %this) unnamed_addr #0 comdat align 2 !dbg !46 { 104entry: 105 call void @llvm.dbg.value(metadata %struct.B* %this, metadata !48, metadata !DIExpression()), !dbg !50 106 %b = getelementptr inbounds %struct.B, %struct.B* %this, i64 0, i32 2, !dbg !51 107 %0 = load i32, i32* %b, align 8, !dbg !51, !tbaa !52 108 ret i32 %0, !dbg !51 109} 110 111declare dso_local void @"?f@D@@UEAAXXZ"(%struct.D*) unnamed_addr #1 112 113; Function Attrs: nounwind uwtable 114define linkonce_odr dso_local i32 @"?get@C@@UEAAHXZ"(%struct.C* %this) unnamed_addr #0 comdat align 2 !dbg !57 { 115entry: 116 call void @llvm.dbg.value(metadata %struct.C* %this, metadata !59, metadata !DIExpression()), !dbg !61 117 %c = getelementptr inbounds %struct.C, %struct.C* %this, i64 0, i32 2, !dbg !62 118 %0 = load i32, i32* %c, align 8, !dbg !62, !tbaa !63 119 ret i32 %0, !dbg !62 120} 121 122; Function Attrs: nounwind readnone speculatable 123declare void @llvm.dbg.value(metadata, metadata, metadata) #2 124 125attributes #0 = { nounwind 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" } 126attributes #1 = { "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-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" } 127attributes #2 = { nounwind readnone speculatable } 128 129!llvm.dbg.cu = !{!2} 130!llvm.module.flags = !{!41, !42, !43, !44} 131!llvm.ident = !{!45} 132 133!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 134!1 = distinct !DIGlobalVariable(name: "d", linkageName: "?d@@3UD@@A", scope: !2, file: !3, line: 8, type: !6, isLocal: false, isDefinition: true) 135!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 7.0.0 (trunk)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5) 136!3 = !DIFile(filename: "t.cpp", directory: "C:\5CPath\5CTo\5CDirectory", checksumkind: CSK_MD5, checksum: "7477d4db6bf8a461a719bcaab9c6d65e") 137!4 = !{} 138!5 = !{!0} 139!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "D", file: !3, line: 4, size: 512, flags: DIFlagTypePassByReference, elements: !7, vtableHolder: !9, identifier: ".?AUD@@") 140!7 = !{!8, !24, !34, !35, !36, !37} 141!8 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !6, baseType: !9, extraData: i32 0) 142!9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "B", file: !3, line: 2, size: 256, flags: DIFlagTypePassByReference, elements: !10, vtableHolder: !9, identifier: ".?AUB@@") 143!10 = !{!11, !16, !17, !19, !20} 144!11 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !9, baseType: !12, offset: 4, flags: DIFlagVirtual, extraData: i32 8) 145!12 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !3, line: 1, size: 32, flags: DIFlagTypePassByValue, elements: !13, identifier: ".?AUA@@") 146!13 = !{!14} 147!14 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !12, file: !3, line: 1, baseType: !15, size: 32) 148!15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 149!16 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type", baseType: null, size: 64) 150!17 = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$B", scope: !3, file: !3, baseType: !18, size: 64, flags: DIFlagArtificial) 151!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64) 152!19 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !9, file: !3, line: 2, baseType: !15, size: 32, offset: 128) 153!20 = !DISubprogram(name: "get", linkageName: "?get@B@@UEAAHXZ", scope: !9, file: !3, line: 2, type: !21, isLocal: false, isDefinition: false, scopeLine: 2, containingType: !9, virtuality: DW_VIRTUALITY_virtual, virtualIndex: 0, flags: DIFlagPrototyped | DIFlagIntroducedVirtual, isOptimized: true) 154!21 = !DISubroutineType(types: !22) 155!22 = !{!15, !23} 156!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 157!24 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !6, baseType: !25, offset: 192, extraData: i32 0) 158!25 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "C", file: !3, line: 3, size: 256, flags: DIFlagTypePassByReference, elements: !26, vtableHolder: !25, identifier: ".?AUC@@") 159!26 = !{!27, !16, !28, !29, !30} 160!27 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !25, baseType: !12, offset: 4, flags: DIFlagVirtual, extraData: i32 8) 161!28 = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$C", scope: !3, file: !3, baseType: !18, size: 64, flags: DIFlagArtificial) 162!29 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !25, file: !3, line: 3, baseType: !15, size: 32, offset: 128) 163!30 = !DISubprogram(name: "get", linkageName: "?get@C@@UEAAHXZ", scope: !25, file: !3, line: 3, type: !31, isLocal: false, isDefinition: false, scopeLine: 3, containingType: !25, virtuality: DW_VIRTUALITY_virtual, virtualIndex: 0, flags: DIFlagPrototyped | DIFlagIntroducedVirtual, isOptimized: true) 164!31 = !DISubroutineType(types: !32) 165!32 = !{!15, !33} 166!33 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !25, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 167!34 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !6, baseType: !12, offset: 4, flags: DIFlagIndirectVirtualBase, extraData: i32 8) 168!35 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type", baseType: null, size: 128) 169!36 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !6, file: !3, line: 6, baseType: !15, size: 32, offset: 384) 170!37 = !DISubprogram(name: "f", linkageName: "?f@D@@UEAAXXZ", scope: !6, file: !3, line: 5, type: !38, isLocal: false, isDefinition: false, scopeLine: 5, containingType: !6, virtuality: DW_VIRTUALITY_virtual, virtualIndex: 1, flags: DIFlagPrototyped | DIFlagIntroducedVirtual, isOptimized: true) 171!38 = !DISubroutineType(types: !39) 172!39 = !{null, !40} 173!40 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 174!41 = !{i32 2, !"CodeView", i32 1} 175!42 = !{i32 2, !"Debug Info Version", i32 3} 176!43 = !{i32 1, !"wchar_size", i32 2} 177!44 = !{i32 7, !"PIC Level", i32 2} 178!45 = !{!"clang version 7.0.0 (trunk)"} 179!46 = distinct !DISubprogram(name: "get", linkageName: "?get@B@@UEAAHXZ", scope: !9, file: !3, line: 2, type: !21, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !2, declaration: !20, retainedNodes: !47) 180!47 = !{!48} 181!48 = !DILocalVariable(name: "this", arg: 1, scope: !46, type: !49, flags: DIFlagArtificial | DIFlagObjectPointer) 182!49 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64) 183!50 = !DILocation(line: 0, scope: !46) 184!51 = !DILocation(line: 2, scope: !46) 185!52 = !{!53, !54, i64 16} 186!53 = !{!"?AUB@@", !54, i64 16} 187!54 = !{!"int", !55, i64 0} 188!55 = !{!"omnipotent char", !56, i64 0} 189!56 = !{!"Simple C++ TBAA"} 190!57 = distinct !DISubprogram(name: "get", linkageName: "?get@C@@UEAAHXZ", scope: !25, file: !3, line: 3, type: !31, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !2, declaration: !30, retainedNodes: !58) 191!58 = !{!59} 192!59 = !DILocalVariable(name: "this", arg: 1, scope: !57, type: !60, flags: DIFlagArtificial | DIFlagObjectPointer) 193!60 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !25, size: 64) 194!61 = !DILocation(line: 0, scope: !57) 195!62 = !DILocation(line: 3, scope: !57) 196!63 = !{!64, !54, i64 16} 197!64 = !{!"?AUC@@", !54, i64 16} 198