@@ -1066,6 +1066,9 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1066
1066
for (VarDecl *VD : Decl->getStoredProperties ()) {
1067
1067
auto memberTy = BaseTy->getTypeOfMember (IGM.getSwiftModule (), VD);
1068
1068
1069
+ auto &TI = IGM.getTypeInfoForUnlowered (
1070
+ IGM.getSILTypes ().getAbstractionPattern (VD), memberTy);
1071
+
1069
1072
if (auto DbgTy = CompletedDebugTypeInfo::getFromTypeInfo (
1070
1073
VD->getInterfaceType (),
1071
1074
IGM.getTypeInfoForUnlowered (
@@ -1186,6 +1189,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1186
1189
llvm::DICompositeType *createVariantType (CompletedDebugTypeInfo DbgTy,
1187
1190
EnumDecl *Decl,
1188
1191
StringRef MangledName,
1192
+ unsigned AlignInBits,
1189
1193
llvm::DIScope *Scope,
1190
1194
llvm::DIFile *File, unsigned Line,
1191
1195
llvm::DINode::DIFlags Flags) {
@@ -1195,7 +1199,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1195
1199
StringRef Name = Decl->getName ().str ();
1196
1200
unsigned SizeInBits = DbgTy.getSizeInBits ();
1197
1201
// Default, since Swift doesn't allow specifying a custom alignment.
1198
- unsigned AlignInBits = 0 ;
1199
1202
auto NumExtraInhabitants = DbgTy.getNumExtraInhabitants ();
1200
1203
1201
1204
// A variant part should actually be a child to a DW_TAG_structure_type
@@ -1235,27 +1238,42 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1235
1238
Elements.push_back (MTy);
1236
1239
}
1237
1240
}
1238
- auto VPTy = DBuilder.createVariantPart (Scope, {}, File, Line, SizeInBits,
1239
- AlignInBits, Flags, nullptr ,
1240
- DBuilder.getOrCreateArray (Elements));
1241
+
1242
+ APInt SpareBitsMask;
1243
+ auto &EnumStrategy =
1244
+ getEnumImplStrategy (IGM, DbgTy.getType ()->getCanonicalType ());
1245
+
1246
+ auto VariantOffsetInBits = 0 ;
1247
+ if (auto SpareBitsMaskInfo = EnumStrategy.calculateSpareBitsMask ()) {
1248
+ SpareBitsMask = SpareBitsMaskInfo->bits ;
1249
+ // The offset of the variant mask in the overall enum.
1250
+ VariantOffsetInBits = SpareBitsMaskInfo->byteOffset * 8 ;
1251
+ }
1252
+
1253
+ auto VPTy = DBuilder.createVariantPart (
1254
+ Scope, {}, File, Line, SizeInBits, AlignInBits, Flags, nullptr ,
1255
+ DBuilder.getOrCreateArray (Elements), /* UniqueIdentifier=*/ " " ,
1256
+ VariantOffsetInBits, SpareBitsMask);
1257
+
1241
1258
auto DITy = DBuilder.createStructType (
1242
1259
Scope, Name, File, Line, SizeInBits, AlignInBits, Flags, nullptr ,
1243
1260
DBuilder.getOrCreateArray (VPTy), llvm::dwarf::DW_LANG_Swift, nullptr ,
1244
- MangledName, NumExtraInhabitants ? *NumExtraInhabitants : 0 );
1261
+ MangledName, NumExtraInhabitants. value_or ( 0 ) );
1245
1262
DBuilder.replaceTemporary (std::move (FwdDecl), DITy);
1246
1263
return DITy;
1247
1264
}
1248
1265
1249
1266
llvm::DICompositeType *createEnumType (CompletedDebugTypeInfo DbgTy,
1250
1267
EnumDecl *Decl, StringRef MangledName,
1268
+ unsigned AlignInBits,
1251
1269
llvm::DIScope *Scope,
1252
1270
llvm::DIFile *File, unsigned Line,
1253
1271
llvm::DINode::DIFlags Flags) {
1254
1272
if (Decl->hasRawType ())
1255
1273
return createRawEnumType (DbgTy, Decl, MangledName, Scope, File, Line,
1256
1274
Flags);
1257
- return createVariantType (DbgTy, Decl, MangledName, Scope, File, Line ,
1258
- Flags);
1275
+ return createVariantType (DbgTy, Decl, MangledName, AlignInBits, Scope, File ,
1276
+ Line, Flags);
1259
1277
}
1260
1278
1261
1279
llvm::DIType *getOrCreateDesugaredType (Type Ty, DebugTypeInfo DbgTy) {
@@ -1868,8 +1886,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1868
1886
unsigned FwdDeclLine = 0 ;
1869
1887
if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes)
1870
1888
if (auto CompletedDbgTy = CompletedDebugTypeInfo::get (DbgTy))
1871
- return createEnumType (*CompletedDbgTy, Decl, MangledName, Scope ,
1872
- L.File , L.Line , Flags);
1889
+ return createEnumType (*CompletedDbgTy, Decl, MangledName, AlignInBits ,
1890
+ Scope, L.File , L.Line , Flags);
1873
1891
return createOpaqueStruct (Scope, Decl->getName ().str (), L.File ,
1874
1892
FwdDeclLine, SizeInBits, AlignInBits, Flags,
1875
1893
MangledName);
0 commit comments