@@ -1125,11 +1125,13 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1125
1125
llvm::DICompositeType *createUnsubstitutedGenericStructOrClassType (
1126
1126
DebugTypeInfo DbgTy, NominalTypeDecl *Decl, Type UnsubstitutedType,
1127
1127
llvm::DIScope *Scope, llvm::DIFile *File, unsigned Line,
1128
- unsigned SizeInBits, unsigned AlignInBits, llvm::DINode::DIFlags Flags,
1129
- llvm::DIType *DerivedFrom, unsigned RuntimeLang, StringRef UniqueID) {
1128
+ llvm::DINode::DIFlags Flags, llvm::DIType *DerivedFrom ,
1129
+ unsigned RuntimeLang, StringRef UniqueID) {
1130
1130
// FIXME: ideally, we'd like to emit this type with no size and alignment at
1131
1131
// all (instead of emitting them as 0). Fix this by changing DIBuilder to
1132
1132
// allow for struct types that have optional size and alignment.
1133
+ unsigned SizeInBits = 0 ;
1134
+ unsigned AlignInBits = 0 ;
1133
1135
StringRef Name = Decl->getName ().str ();
1134
1136
auto FwdDecl = createStructForwardDecl (DbgTy, Decl, Scope, File, Line,
1135
1137
SizeInBits, Flags, UniqueID, Name);
@@ -1172,8 +1174,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1172
1174
std::string DeclTypeMangledName = Mangler.mangleTypeForDebugger (
1173
1175
UnsubstitutedTy->mapTypeOutOfContext (), {});
1174
1176
if (DeclTypeMangledName == MangledName) {
1175
- return createUnsubstitutedVariantType (DbgTy, Decl, MangledName,
1176
- SizeInBits, AlignInBits, Scope,
1177
+ return createUnsubstitutedVariantType (DbgTy, Decl, MangledName, Scope,
1177
1178
File, 0 , Flags);
1178
1179
}
1179
1180
auto FwdDecl = llvm::TempDIType (DBuilder.createReplaceableCompositeType (
@@ -1232,9 +1233,8 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
1232
1233
Mangler.mangleTypeForDebugger (UnsubstitutedTy->mapTypeOutOfContext (), {});
1233
1234
if (DeclTypeMangledName == MangledName) {
1234
1235
return createUnsubstitutedGenericStructOrClassType (
1235
- DbgTy, Decl, UnsubstitutedTy, Scope, File, Line, SizeInBits,
1236
- AlignInBits, Flags, nullptr , llvm::dwarf::DW_LANG_Swift,
1237
- DeclTypeMangledName);
1236
+ DbgTy, Decl, UnsubstitutedTy, Scope, File, Line, Flags, nullptr ,
1237
+ llvm::dwarf::DW_LANG_Swift, DeclTypeMangledName);
1238
1238
}
1239
1239
// Force the creation of the unsubstituted type, don't create it
1240
1240
// directly so it goes through all the caching/verification logic.
@@ -1327,7 +1327,7 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
1327
1327
llvm::DIFile *File, unsigned Line,
1328
1328
llvm::DINode::DIFlags Flags) {
1329
1329
assert (!Decl->getRawType () &&
1330
- " Attempting to create variant debug info from raw enum!" );
1330
+ " Attempting to create variant debug info from raw enum!" );;
1331
1331
1332
1332
StringRef Name = Decl->getName ().str ();
1333
1333
unsigned SizeInBits = DbgTy.getSizeInBits ();
@@ -1399,7 +1399,6 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
1399
1399
llvm::DICompositeType *
1400
1400
createUnsubstitutedVariantType (DebugTypeInfo DbgTy, EnumDecl *Decl,
1401
1401
StringRef MangledName,
1402
- unsigned SizeInBits, unsigned AlignInBits,
1403
1402
llvm::DIScope *Scope, llvm::DIFile *File,
1404
1403
unsigned Line, llvm::DINode::DIFlags Flags) {
1405
1404
assert (!Decl->getRawType () &&
@@ -1408,6 +1407,8 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
1408
1407
StringRef Name = Decl->getName ().str ();
1409
1408
auto NumExtraInhabitants = DbgTy.getNumExtraInhabitants ();
1410
1409
1410
+ unsigned SizeInBits = 0 ;
1411
+ unsigned AlignInBits = 0 ;
1411
1412
// A variant part should actually be a child to a DW_TAG_structure_type
1412
1413
// according to the DWARF spec.
1413
1414
auto FwdDecl = llvm::TempDIType (DBuilder.createReplaceableCompositeType (
@@ -2082,7 +2083,7 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
2082
2083
auto L = getFileAndLocation (Decl);
2083
2084
unsigned FwdDeclLine = 0 ;
2084
2085
if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes) {
2085
- if (EnumTy->isSpecialized ())
2086
+ if (EnumTy->isSpecialized () && !Decl-> hasRawType () )
2086
2087
return createSpecializedEnumType (EnumTy, Decl, MangledName,
2087
2088
SizeInBits, AlignInBits, Scope, File,
2088
2089
FwdDeclLine, Flags);
@@ -2262,6 +2263,12 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
2262
2263
unsigned CachedSizeInBits = getSizeInBits (CachedType);
2263
2264
if ((SizeInBits && CachedSizeInBits != *SizeInBits) ||
2264
2265
(!SizeInBits && CachedSizeInBits)) {
2266
+ // In some situation a specialized type is emitted with size 0, even if the real
2267
+ // type has a size.
2268
+ if (DbgTy.getType ()->isSpecialized () && SizeInBits && *SizeInBits > 0 &&
2269
+ CachedSizeInBits == 0 )
2270
+ return true ;
2271
+
2265
2272
CachedType->dump ();
2266
2273
DbgTy.dump ();
2267
2274
llvm::errs () << " SizeInBits = " << SizeInBits << " \n " ;
0 commit comments