Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 6a29f67

Browse files
committed
DebugInfo: emit the definition of types when construction vtables are required as these types may never end up emitting the full class data
This might be able to be optimized further by only doing this in the absence of a key function, but it doesn't look like GCC is doing that so I'm not rushing to do it just yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189022 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent d4a03db commit 6a29f67

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

Diff for: lib/CodeGen/CGVTables.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,9 @@ CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD,
685685
bool BaseIsVirtual,
686686
llvm::GlobalVariable::LinkageTypes Linkage,
687687
VTableAddressPointsMapTy& AddressPoints) {
688+
if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
689+
DI->completeClassData(Base.getBase());
690+
688691
OwningPtr<VTableLayout> VTLayout(
689692
VTContext.createConstructionVTableLayout(Base.getBase(),
690693
Base.getBaseOffset(),
@@ -822,15 +825,15 @@ void CodeGenModule::EmitVTable(CXXRecordDecl *theClass, bool isRequired) {
822825

823826
void
824827
CodeGenVTables::GenerateClassData(const CXXRecordDecl *RD) {
828+
if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
829+
DI->completeClassData(RD);
830+
825831
if (VFTContext.isValid()) {
826832
// FIXME: This is a temporary solution to force generation of vftables in
827833
// Microsoft ABI. Remove when we thread VFTableContext through CodeGen.
828834
VFTContext->getVFPtrOffsets(RD);
829835
}
830836

831-
if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
832-
DI->completeClassData(RD);
833-
834837
// First off, check whether we've already emitted the v-table and
835838
// associated stuff.
836839
llvm::GlobalVariable *VTable = GetAddrOfVTable(RD);

Diff for: test/CodeGenCXX/debug-info-class.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ struct G {
5252
};
5353
};
5454

55+
struct H {};
56+
struct I : virtual H {};
57+
struct J : I {};
58+
J j;
59+
5560
struct A {
5661
int one;
5762
static const int HdrSize = 52;
@@ -103,6 +108,8 @@ int main(int argc, char **argv) {
103108
// CHECK: [[D_MEM]] = metadata !{metadata [[D_FUNC:![0-9]*]]}
104109
// CHECK: [[D_FUNC]] = {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [func]
105110

111+
// CHECK: ; [ DW_TAG_structure_type ] [I] {{.*}} [def]
112+
106113
// CHECK: [[F_I_DEF:![0-9]*]] = {{.*}}, metadata [[F_I:![0-9]*]]} ; [ DW_TAG_variable ] [i]
107114
// CHECK: [[F_I]] = {{.*}} ; [ DW_TAG_member ] [i]
108115
// CHECK: [[F:![0-9]*]] = {{.*}} metadata [[F_MEM:![0-9]*]], i32 0, null, null} ; [ DW_TAG_structure_type ] [F] {{.*}} [def]
@@ -117,5 +124,5 @@ int main(int argc, char **argv) {
117124
// CHECK: [[G_INNER_MEM]] = metadata !{metadata [[G_INNER_I:![0-9]*]]}
118125
// CHECK: [[G_INNER_I]] = {{.*}} ; [ DW_TAG_member ] [j] {{.*}} [from int]
119126

120-
// CHECK: ![[EXCEPTLOC]] = metadata !{i32 79,
121-
// CHECK: ![[RETLOC]] = metadata !{i32 78,
127+
// CHECK: ![[EXCEPTLOC]] = metadata !{i32 84,
128+
// CHECK: ![[RETLOC]] = metadata !{i32 83,

0 commit comments

Comments
 (0)