• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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; };
7; struct C : virtual A { int 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; D's field list comes first.
16; CHECK:        FieldList ({{.*}}) {
17; CHECK-NEXT:     TypeLeafKind: LF_FIELDLIST (0x1203)
18; CHECK-NEXT:     BaseClass {
19; CHECK-NEXT:       AccessSpecifier: Public (0x3)
20; CHECK-NEXT:       BaseType: B ({{.*}})
21; CHECK-NEXT:       BaseOffset: 0x8
22; CHECK-NEXT:     }
23; CHECK-NEXT:     BaseClass {
24; CHECK-NEXT:       AccessSpecifier: Public (0x3)
25; CHECK-NEXT:       BaseType: C ({{.*}})
26; CHECK-NEXT:       BaseOffset: 0x18
27; CHECK-NEXT:     }
28; CHECK:        }
29
30; Then B's field list.
31; CHECK:        FieldList ({{.*}}) {
32; CHECK-NEXT:     TypeLeafKind: LF_FIELDLIST (0x1203)
33; CHECK-NEXT:     VirtualBaseClass {
34; CHECK-NEXT:       AccessSpecifier: Public (0x3)
35; CHECK-NEXT:       BaseType: A ({{.*}})
36; CHECK-NEXT:       VBPtrType: const int* ({{.*}})
37; CHECK-NEXT:       VBPtrOffset: 0x0
38; CHECK-NEXT:       VBTableIndex: 0x1
39; CHECK-NEXT:     }
40; CHECK:        }
41
42; Then C's field list.
43; CHECK:        FieldList ({{.*}}) {
44; CHECK-NEXT:     TypeLeafKind: LF_FIELDLIST (0x1203)
45; CHECK-NEXT:     VirtualBaseClass {
46; CHECK-NEXT:       AccessSpecifier: Public (0x3)
47; CHECK-NEXT:       BaseType: A ({{.*}})
48; CHECK-NEXT:       VBPtrType: const int* ({{.*}})
49; CHECK-NEXT:       VBPtrOffset: 0x0
50; CHECK-NEXT:       VBTableIndex: 0x1
51; CHECK-NEXT:     }
52; CHECK:        }
53
54; ModuleID = 't.cpp'
55source_filename = "t.cpp"
56target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
57target triple = "x86_64-pc-windows-msvc19.0.23918"
58
59%struct.D = type { i32 (...)**, %struct.B.base, %struct.C.base, i32, [4 x i8], %struct.A }
60%struct.B.base = type { i32*, i32 }
61%struct.C.base = type { i32*, i32 }
62%struct.A = type { i32 }
63%struct.B = type { i32*, i32, [4 x i8], %struct.A }
64%struct.C = type { i32*, i32, [4 x i8], %struct.A }
65
66$"\01??0D@@QEAA@XZ" = comdat any
67
68$"\01??0B@@QEAA@XZ" = comdat any
69
70$"\01??0C@@QEAA@XZ" = comdat any
71
72$"\01??_8D@@7BB@@@" = comdat any
73
74$"\01??_8D@@7BC@@@" = comdat any
75
76$"\01??_7D@@6B@" = comdat any
77
78$"\01??_8B@@7B@" = comdat any
79
80$"\01??_8C@@7B@" = comdat any
81
82@"\01?d@@3UD@@A" = global %struct.D zeroinitializer, align 8
83@"\01??_8D@@7BB@@@" = linkonce_odr unnamed_addr constant [2 x i32] [i32 0, i32 40], comdat
84@"\01??_8D@@7BC@@@" = linkonce_odr unnamed_addr constant [2 x i32] [i32 0, i32 24], comdat
85@"\01??_7D@@6B@" = linkonce_odr unnamed_addr constant [1 x i8*] [i8* bitcast (void (%struct.D*)* @"\01?f@D@@UEAAXXZ" to i8*)], comdat
86@"\01??_8B@@7B@" = linkonce_odr unnamed_addr constant [2 x i32] [i32 0, i32 16], comdat
87@"\01??_8C@@7B@" = linkonce_odr unnamed_addr constant [2 x i32] [i32 0, i32 16], comdat
88@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_t.cpp, i8* null }]
89
90; Function Attrs: uwtable
91define internal void @"\01??__Ed@@YAXXZ"() #0 !dbg !37 {
92entry:
93  %call = call %struct.D* @"\01??0D@@QEAA@XZ"(%struct.D* @"\01?d@@3UD@@A", i32 1) #4, !dbg !40
94  ret void, !dbg !40
95}
96
97; Function Attrs: inlinehint nounwind uwtable
98define linkonce_odr %struct.D* @"\01??0D@@QEAA@XZ"(%struct.D* returned %this, i32 %is_most_derived) unnamed_addr #1 comdat align 2 !dbg !41 {
99entry:
100  %retval = alloca %struct.D*, align 8
101  %is_most_derived.addr = alloca i32, align 4
102  %this.addr = alloca %struct.D*, align 8
103  store i32 %is_most_derived, i32* %is_most_derived.addr, align 4
104  call void @llvm.dbg.declare(metadata i32* %is_most_derived.addr, metadata !43, metadata !44), !dbg !45
105  store %struct.D* %this, %struct.D** %this.addr, align 8
106  call void @llvm.dbg.declare(metadata %struct.D** %this.addr, metadata !46, metadata !44), !dbg !45
107  %this1 = load %struct.D*, %struct.D** %this.addr, align 8
108  store %struct.D* %this1, %struct.D** %retval, align 8
109  %is_most_derived2 = load i32, i32* %is_most_derived.addr, align 4
110  %is_complete_object = icmp ne i32 %is_most_derived2, 0, !dbg !48
111  br i1 %is_complete_object, label %ctor.init_vbases, label %ctor.skip_vbases, !dbg !48
112
113ctor.init_vbases:                                 ; preds = %entry
114  %this.int8 = bitcast %struct.D* %this1 to i8*, !dbg !48
115  %0 = getelementptr inbounds i8, i8* %this.int8, i64 8, !dbg !48
116  %vbptr.D = bitcast i8* %0 to i32**, !dbg !48
117  store i32* getelementptr inbounds ([2 x i32], [2 x i32]* @"\01??_8D@@7BB@@@", i32 0, i32 0), i32** %vbptr.D, align 8, !dbg !48
118  %1 = getelementptr inbounds i8, i8* %this.int8, i64 24, !dbg !48
119  %vbptr.C = bitcast i8* %1 to i32**, !dbg !48
120  store i32* getelementptr inbounds ([2 x i32], [2 x i32]* @"\01??_8D@@7BC@@@", i32 0, i32 0), i32** %vbptr.C, align 8, !dbg !48
121  %2 = bitcast %struct.D* %this1 to i8*, !dbg !48
122  %3 = getelementptr inbounds i8, i8* %2, i64 48, !dbg !48
123  %4 = bitcast i8* %3 to %struct.A*, !dbg !48
124  br label %ctor.skip_vbases, !dbg !48
125
126ctor.skip_vbases:                                 ; preds = %ctor.init_vbases, %entry
127  %5 = bitcast %struct.D* %this1 to i8*, !dbg !48
128  %6 = getelementptr inbounds i8, i8* %5, i64 8, !dbg !48
129  %7 = bitcast i8* %6 to %struct.B*, !dbg !48
130  %call = call %struct.B* @"\01??0B@@QEAA@XZ"(%struct.B* %7, i32 0) #4, !dbg !48
131  %8 = bitcast %struct.D* %this1 to i8*, !dbg !48
132  %9 = getelementptr inbounds i8, i8* %8, i64 24, !dbg !48
133  %10 = bitcast i8* %9 to %struct.C*, !dbg !48
134  %call3 = call %struct.C* @"\01??0C@@QEAA@XZ"(%struct.C* %10, i32 0) #4, !dbg !48
135  %11 = bitcast %struct.D* %this1 to i32 (...)***, !dbg !48
136  store i32 (...)** bitcast ([1 x i8*]* @"\01??_7D@@6B@" to i32 (...)**), i32 (...)*** %11, align 8, !dbg !48
137  %12 = load %struct.D*, %struct.D** %retval, align 8, !dbg !48
138  ret %struct.D* %12, !dbg !48
139}
140
141; Function Attrs: nounwind readnone
142declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
143
144; Function Attrs: inlinehint nounwind uwtable
145define linkonce_odr %struct.B* @"\01??0B@@QEAA@XZ"(%struct.B* returned %this, i32 %is_most_derived) unnamed_addr #1 comdat align 2 !dbg !49 {
146entry:
147  %retval = alloca %struct.B*, align 8
148  %is_most_derived.addr = alloca i32, align 4
149  %this.addr = alloca %struct.B*, align 8
150  store i32 %is_most_derived, i32* %is_most_derived.addr, align 4
151  call void @llvm.dbg.declare(metadata i32* %is_most_derived.addr, metadata !54, metadata !44), !dbg !55
152  store %struct.B* %this, %struct.B** %this.addr, align 8
153  call void @llvm.dbg.declare(metadata %struct.B** %this.addr, metadata !56, metadata !44), !dbg !55
154  %this1 = load %struct.B*, %struct.B** %this.addr, align 8
155  store %struct.B* %this1, %struct.B** %retval, align 8
156  %is_most_derived2 = load i32, i32* %is_most_derived.addr, align 4
157  %is_complete_object = icmp ne i32 %is_most_derived2, 0, !dbg !58
158  br i1 %is_complete_object, label %ctor.init_vbases, label %ctor.skip_vbases, !dbg !58
159
160ctor.init_vbases:                                 ; preds = %entry
161  %this.int8 = bitcast %struct.B* %this1 to i8*, !dbg !58
162  %0 = getelementptr inbounds i8, i8* %this.int8, i64 0, !dbg !58
163  %vbptr.B = bitcast i8* %0 to i32**, !dbg !58
164  store i32* getelementptr inbounds ([2 x i32], [2 x i32]* @"\01??_8B@@7B@", i32 0, i32 0), i32** %vbptr.B, align 8, !dbg !58
165  %1 = bitcast %struct.B* %this1 to i8*, !dbg !58
166  %2 = getelementptr inbounds i8, i8* %1, i64 16, !dbg !58
167  %3 = bitcast i8* %2 to %struct.A*, !dbg !58
168  br label %ctor.skip_vbases, !dbg !58
169
170ctor.skip_vbases:                                 ; preds = %ctor.init_vbases, %entry
171  %4 = load %struct.B*, %struct.B** %retval, align 8, !dbg !58
172  ret %struct.B* %4, !dbg !58
173}
174
175; Function Attrs: inlinehint nounwind uwtable
176define linkonce_odr %struct.C* @"\01??0C@@QEAA@XZ"(%struct.C* returned %this, i32 %is_most_derived) unnamed_addr #1 comdat align 2 !dbg !59 {
177entry:
178  %retval = alloca %struct.C*, align 8
179  %is_most_derived.addr = alloca i32, align 4
180  %this.addr = alloca %struct.C*, align 8
181  store i32 %is_most_derived, i32* %is_most_derived.addr, align 4
182  call void @llvm.dbg.declare(metadata i32* %is_most_derived.addr, metadata !64, metadata !44), !dbg !65
183  store %struct.C* %this, %struct.C** %this.addr, align 8
184  call void @llvm.dbg.declare(metadata %struct.C** %this.addr, metadata !66, metadata !44), !dbg !65
185  %this1 = load %struct.C*, %struct.C** %this.addr, align 8
186  store %struct.C* %this1, %struct.C** %retval, align 8
187  %is_most_derived2 = load i32, i32* %is_most_derived.addr, align 4
188  %is_complete_object = icmp ne i32 %is_most_derived2, 0, !dbg !68
189  br i1 %is_complete_object, label %ctor.init_vbases, label %ctor.skip_vbases, !dbg !68
190
191ctor.init_vbases:                                 ; preds = %entry
192  %this.int8 = bitcast %struct.C* %this1 to i8*, !dbg !68
193  %0 = getelementptr inbounds i8, i8* %this.int8, i64 0, !dbg !68
194  %vbptr.C = bitcast i8* %0 to i32**, !dbg !68
195  store i32* getelementptr inbounds ([2 x i32], [2 x i32]* @"\01??_8C@@7B@", i32 0, i32 0), i32** %vbptr.C, align 8, !dbg !68
196  %1 = bitcast %struct.C* %this1 to i8*, !dbg !68
197  %2 = getelementptr inbounds i8, i8* %1, i64 16, !dbg !68
198  %3 = bitcast i8* %2 to %struct.A*, !dbg !68
199  br label %ctor.skip_vbases, !dbg !68
200
201ctor.skip_vbases:                                 ; preds = %ctor.init_vbases, %entry
202  %4 = load %struct.C*, %struct.C** %retval, align 8, !dbg !68
203  ret %struct.C* %4, !dbg !68
204}
205
206declare void @"\01?f@D@@UEAAXXZ"(%struct.D*) unnamed_addr #3
207
208; Function Attrs: uwtable
209define internal void @_GLOBAL__sub_I_t.cpp() #0 !dbg !69 {
210entry:
211  call void @"\01??__Ed@@YAXXZ"(), !dbg !71
212  ret void
213}
214
215attributes #0 = { 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" }
216attributes #1 = { inlinehint 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" }
217attributes #2 = { nounwind readnone }
218attributes #3 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="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" }
219attributes #4 = { nounwind }
220
221!llvm.dbg.cu = !{!0}
222!llvm.module.flags = !{!33, !34, !35}
223!llvm.ident = !{!36}
224
225!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, globals: !3)
226!1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
227!2 = !{}
228!3 = !{!4}
229!4 = distinct !DIGlobalVariable(name: "d", linkageName: "\01?d@@3UD@@A", scope: !0, file: !1, line: 9, type: !5, isLocal: false, isDefinition: true, variable: %struct.D* @"\01?d@@3UD@@A")
230!5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "D", file: !1, line: 4, size: 448, align: 64, elements: !6, vtableHolder: !5, identifier: ".?AUD@@")
231!6 = !{!7, !21, !27, !28, !29}
232!7 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !5, baseType: !8, offset: 64)
233!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "B", file: !1, line: 2, size: 192, align: 64, elements: !9, vtableHolder: !8, identifier: ".?AUB@@")
234!9 = !{!10, !15, !20}
235!10 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !8, baseType: !11, offset: 4, flags: DIFlagVirtual)
236!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !1, line: 1, size: 32, align: 32, elements: !12, identifier: ".?AUA@@")
237!12 = !{!13}
238!13 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !11, file: !1, line: 1, baseType: !14, size: 32, align: 32)
239!14 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
240!15 = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$B", scope: !1, file: !1, baseType: !16, size: 64, flags: DIFlagArtificial)
241!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !17, size: 64)
242!17 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type", baseType: !18, size: 64)
243!18 = !DISubroutineType(types: !19)
244!19 = !{!14}
245!20 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !8, file: !1, line: 2, baseType: !14, size: 32, align: 32, offset: 64)
246!21 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !5, baseType: !22, offset: 192)
247!22 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "C", file: !1, line: 3, size: 192, align: 64, elements: !23, vtableHolder: !22, identifier: ".?AUC@@")
248!23 = !{!24, !25, !26}
249!24 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !22, baseType: !11, offset: 4, flags: DIFlagVirtual)
250!25 = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$C", scope: !1, file: !1, baseType: !16, size: 64, flags: DIFlagArtificial)
251!26 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !22, file: !1, line: 3, baseType: !14, size: 32, align: 32, offset: 64)
252!27 = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$D", scope: !1, file: !1, baseType: !16, size: 64, flags: DIFlagArtificial)
253!28 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !5, file: !1, line: 6, baseType: !14, size: 32, align: 32, offset: 320)
254!29 = !DISubprogram(name: "f", linkageName: "\01?f@D@@UEAAXXZ", scope: !5, file: !1, line: 5, type: !30, isLocal: false, isDefinition: false, scopeLine: 5, containingType: !5, virtuality: DW_VIRTUALITY_virtual, virtualIndex: 0, flags: DIFlagPrototyped | DIFlagIntroducedVirtual, isOptimized: false)
255!30 = !DISubroutineType(types: !31)
256!31 = !{null, !32}
257!32 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
258!33 = !{i32 2, !"CodeView", i32 1}
259!34 = !{i32 2, !"Debug Info Version", i32 3}
260!35 = !{i32 1, !"PIC Level", i32 2}
261!36 = !{!"clang version 3.9.0 "}
262!37 = distinct !DISubprogram(name: "??__Ed@@YAXXZ", scope: !1, file: !1, line: 9, type: !38, isLocal: true, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
263!38 = !DISubroutineType(types: !39)
264!39 = !{null}
265!40 = !DILocation(line: 9, column: 3, scope: !37)
266!41 = distinct !DISubprogram(name: "D", linkageName: "\01??0D@@QEAA@XZ", scope: !5, file: !1, line: 4, type: !30, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !42, variables: !2)
267!42 = !DISubprogram(name: "D", scope: !5, type: !30, isLocal: false, isDefinition: false, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
268!43 = !DILocalVariable(name: "is_most_derived", arg: 2, scope: !41, type: !14, flags: DIFlagArtificial)
269!44 = !DIExpression()
270!45 = !DILocation(line: 0, scope: !41)
271!46 = !DILocalVariable(name: "this", arg: 1, scope: !41, type: !47, flags: DIFlagArtificial | DIFlagObjectPointer)
272!47 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64, align: 64)
273!48 = !DILocation(line: 4, column: 8, scope: !41)
274!49 = distinct !DISubprogram(name: "B", linkageName: "\01??0B@@QEAA@XZ", scope: !8, file: !1, line: 2, type: !50, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !53, variables: !2)
275!50 = !DISubroutineType(types: !51)
276!51 = !{null, !52}
277!52 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
278!53 = !DISubprogram(name: "B", scope: !8, type: !50, isLocal: false, isDefinition: false, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
279!54 = !DILocalVariable(name: "is_most_derived", arg: 2, scope: !49, type: !14, flags: DIFlagArtificial)
280!55 = !DILocation(line: 0, scope: !49)
281!56 = !DILocalVariable(name: "this", arg: 1, scope: !49, type: !57, flags: DIFlagArtificial | DIFlagObjectPointer)
282!57 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, align: 64)
283!58 = !DILocation(line: 2, column: 8, scope: !49)
284!59 = distinct !DISubprogram(name: "C", linkageName: "\01??0C@@QEAA@XZ", scope: !22, file: !1, line: 3, type: !60, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !63, variables: !2)
285!60 = !DISubroutineType(types: !61)
286!61 = !{null, !62}
287!62 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
288!63 = !DISubprogram(name: "C", scope: !22, type: !60, isLocal: false, isDefinition: false, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
289!64 = !DILocalVariable(name: "is_most_derived", arg: 2, scope: !59, type: !14, flags: DIFlagArtificial)
290!65 = !DILocation(line: 0, scope: !59)
291!66 = !DILocalVariable(name: "this", arg: 1, scope: !59, type: !67, flags: DIFlagArtificial | DIFlagObjectPointer)
292!67 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 64, align: 64)
293!68 = !DILocation(line: 3, column: 8, scope: !59)
294!69 = distinct !DISubprogram(linkageName: "_GLOBAL__sub_I_t.cpp", scope: !1, file: !1, type: !70, isLocal: true, isDefinition: true, flags: DIFlagArtificial, isOptimized: false, unit: !0, variables: !2)
295!70 = !DISubroutineType(types: !2)
296!71 = !DILocation(line: 0, scope: !69)
297