@@ -1134,11 +1134,13 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1134
1134
llvm::DICompositeType *createUnsubstitutedGenericStructOrClassType (
1135
1135
DebugTypeInfo DbgTy, NominalTypeDecl *Decl, Type UnsubstitutedType,
1136
1136
llvm::DIScope *Scope, llvm::DIFile *File, unsigned Line,
1137
- unsigned SizeInBits, unsigned AlignInBits, llvm::DINode::DIFlags Flags,
1138
- llvm::DIType *DerivedFrom, unsigned RuntimeLang, StringRef UniqueID) {
1137
+ llvm::DINode::DIFlags Flags, llvm::DIType *DerivedFrom ,
1138
+ unsigned RuntimeLang, StringRef UniqueID) {
1139
1139
// FIXME: ideally, we'd like to emit this type with no size and alignment at
1140
1140
// all (instead of emitting them as 0). Fix this by changing DIBuilder to
1141
1141
// allow for struct types that have optional size and alignment.
1142
+ unsigned SizeInBits = 0 ;
1143
+ unsigned AlignInBits = 0 ;
1142
1144
StringRef Name = Decl->getName ().str ();
1143
1145
auto FwdDecl = createStructForwardDecl (DbgTy, Decl, Scope, File, Line,
1144
1146
SizeInBits, Flags, UniqueID, Name);
@@ -1181,8 +1183,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1181
1183
std::string DeclTypeMangledName = Mangler.mangleTypeForDebugger (
1182
1184
UnsubstitutedTy->mapTypeOutOfContext (), {});
1183
1185
if (DeclTypeMangledName == MangledName) {
1184
- return createUnsubstitutedVariantType (DbgTy, Decl, MangledName,
1185
- SizeInBits, AlignInBits, Scope,
1186
+ return createUnsubstitutedVariantType (DbgTy, Decl, MangledName, Scope,
1186
1187
File, 0 , Flags);
1187
1188
}
1188
1189
auto FwdDecl = llvm::TempDIType (DBuilder.createReplaceableCompositeType (
@@ -1241,9 +1242,8 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
1241
1242
Mangler.mangleTypeForDebugger (UnsubstitutedTy->mapTypeOutOfContext (), {});
1242
1243
if (DeclTypeMangledName == MangledName) {
1243
1244
return createUnsubstitutedGenericStructOrClassType (
1244
- DbgTy, Decl, UnsubstitutedTy, Scope, File, Line, SizeInBits,
1245
- AlignInBits, Flags, nullptr , llvm::dwarf::DW_LANG_Swift,
1246
- DeclTypeMangledName);
1245
+ DbgTy, Decl, UnsubstitutedTy, Scope, File, Line, Flags, nullptr ,
1246
+ llvm::dwarf::DW_LANG_Swift, DeclTypeMangledName);
1247
1247
}
1248
1248
// Force the creation of the unsubstituted type, don't create it
1249
1249
// directly so it goes through all the caching/verification logic.
@@ -1336,7 +1336,7 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
1336
1336
llvm::DIFile *File, unsigned Line,
1337
1337
llvm::DINode::DIFlags Flags) {
1338
1338
assert (!Decl->getRawType () &&
1339
- " Attempting to create variant debug info from raw enum!" );
1339
+ " Attempting to create variant debug info from raw enum!" );;
1340
1340
1341
1341
StringRef Name = Decl->getName ().str ();
1342
1342
unsigned SizeInBits = DbgTy.getSizeInBits ();
@@ -1408,7 +1408,6 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
1408
1408
llvm::DICompositeType *
1409
1409
createUnsubstitutedVariantType (DebugTypeInfo DbgTy, EnumDecl *Decl,
1410
1410
StringRef MangledName,
1411
- unsigned SizeInBits, unsigned AlignInBits,
1412
1411
llvm::DIScope *Scope, llvm::DIFile *File,
1413
1412
unsigned Line, llvm::DINode::DIFlags Flags) {
1414
1413
assert (!Decl->getRawType () &&
@@ -1417,6 +1416,8 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
1417
1416
StringRef Name = Decl->getName ().str ();
1418
1417
auto NumExtraInhabitants = DbgTy.getNumExtraInhabitants ();
1419
1418
1419
+ unsigned SizeInBits = 0 ;
1420
+ unsigned AlignInBits = 0 ;
1420
1421
// A variant part should actually be a child to a DW_TAG_structure_type
1421
1422
// according to the DWARF spec.
1422
1423
llvm::TempDICompositeType FwdDecl (DBuilder.createReplaceableCompositeType (
@@ -2091,7 +2092,7 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
2091
2092
auto L = getFileAndLocation (Decl);
2092
2093
unsigned FwdDeclLine = 0 ;
2093
2094
if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes) {
2094
- if (EnumTy->isSpecialized ())
2095
+ if (EnumTy->isSpecialized () && !Decl-> hasRawType () )
2095
2096
return createSpecializedEnumType (EnumTy, Decl, MangledName,
2096
2097
SizeInBits, AlignInBits, Scope, File,
2097
2098
FwdDeclLine, Flags);
@@ -2271,6 +2272,12 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
2271
2272
unsigned CachedSizeInBits = getSizeInBits (CachedType);
2272
2273
if ((SizeInBits && CachedSizeInBits != *SizeInBits) ||
2273
2274
(!SizeInBits && CachedSizeInBits)) {
2275
+ // In some situation a specialized type is emitted with size 0, even if the real
2276
+ // type has a size.
2277
+ if (DbgTy.getType ()->isSpecialized () && SizeInBits && *SizeInBits > 0 &&
2278
+ CachedSizeInBits == 0 )
2279
+ return true ;
2280
+
2274
2281
CachedType->dump ();
2275
2282
DbgTy.dump ();
2276
2283
llvm::errs () << " SizeInBits = " << SizeInBits << " \n " ;
0 commit comments