@@ -1066,6 +1066,9 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
10661066 for (VarDecl *VD : Decl->getStoredProperties ()) {
10671067 auto memberTy = BaseTy->getTypeOfMember (IGM.getSwiftModule (), VD);
10681068
1069+ auto &TI = IGM.getTypeInfoForUnlowered (
1070+ IGM.getSILTypes ().getAbstractionPattern (VD), memberTy);
1071+
10691072 if (auto DbgTy = CompletedDebugTypeInfo::getFromTypeInfo (
10701073 VD->getInterfaceType (),
10711074 IGM.getTypeInfoForUnlowered (
@@ -1186,6 +1189,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
11861189 llvm::DICompositeType *createVariantType (CompletedDebugTypeInfo DbgTy,
11871190 EnumDecl *Decl,
11881191 StringRef MangledName,
1192+ unsigned AlignInBits,
11891193 llvm::DIScope *Scope,
11901194 llvm::DIFile *File, unsigned Line,
11911195 llvm::DINode::DIFlags Flags) {
@@ -1195,7 +1199,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
11951199 StringRef Name = Decl->getName ().str ();
11961200 unsigned SizeInBits = DbgTy.getSizeInBits ();
11971201 // Default, since Swift doesn't allow specifying a custom alignment.
1198- unsigned AlignInBits = 0 ;
11991202 auto NumExtraInhabitants = DbgTy.getNumExtraInhabitants ();
12001203
12011204 // A variant part should actually be a child to a DW_TAG_structure_type
@@ -1235,27 +1238,42 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
12351238 Elements.push_back (MTy);
12361239 }
12371240 }
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+
12411258 auto DITy = DBuilder.createStructType (
12421259 Scope, Name, File, Line, SizeInBits, AlignInBits, Flags, nullptr ,
12431260 DBuilder.getOrCreateArray (VPTy), llvm::dwarf::DW_LANG_Swift, nullptr ,
1244- MangledName, NumExtraInhabitants ? *NumExtraInhabitants : 0 );
1261+ MangledName, NumExtraInhabitants. value_or ( 0 ) );
12451262 DBuilder.replaceTemporary (std::move (FwdDecl), DITy);
12461263 return DITy;
12471264 }
12481265
12491266 llvm::DICompositeType *createEnumType (CompletedDebugTypeInfo DbgTy,
12501267 EnumDecl *Decl, StringRef MangledName,
1268+ unsigned AlignInBits,
12511269 llvm::DIScope *Scope,
12521270 llvm::DIFile *File, unsigned Line,
12531271 llvm::DINode::DIFlags Flags) {
12541272 if (Decl->hasRawType ())
12551273 return createRawEnumType (DbgTy, Decl, MangledName, Scope, File, Line,
12561274 Flags);
1257- return createVariantType (DbgTy, Decl, MangledName, Scope, File, Line ,
1258- Flags);
1275+ return createVariantType (DbgTy, Decl, MangledName, AlignInBits, Scope, File ,
1276+ Line, Flags);
12591277 }
12601278
12611279 llvm::DIType *getOrCreateDesugaredType (Type Ty, DebugTypeInfo DbgTy) {
@@ -1868,8 +1886,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
18681886 unsigned FwdDeclLine = 0 ;
18691887 if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes)
18701888 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);
18731891 return createOpaqueStruct (Scope, Decl->getName ().str (), L.File ,
18741892 FwdDeclLine, SizeInBits, AlignInBits, Flags,
18751893 MangledName);
0 commit comments