@@ -1044,11 +1044,10 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1044
1044
llvm::DINode::DIFlags Flags) {
1045
1045
unsigned SizeOfByte = CI.getTargetInfo ().getCharWidth ();
1046
1046
auto *Ty = getOrCreateType (DbgTy);
1047
+ auto SizeInBits = getSizeInBits (Ty);
1047
1048
auto *DITy = DBuilder.createMemberType (
1048
- Scope, Name, File, 0 ,
1049
- DbgTy.getRawSizeInBits () ? *DbgTy.getRawSizeInBits () : 0 , 0 ,
1050
- OffsetInBits, Flags, Ty);
1051
- OffsetInBits += getSizeInBits (Ty);
1049
+ Scope, Name, File, 0 , SizeInBits, 0 , OffsetInBits, Flags, Ty);
1050
+ OffsetInBits += SizeInBits;
1052
1051
OffsetInBits = llvm::alignTo (OffsetInBits,
1053
1052
SizeOfByte * DbgTy.getAlignment ().getValue ());
1054
1053
return DITy;
@@ -1350,14 +1349,14 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1350
1349
// Create debug information for an enum with no raw type.
1351
1350
llvm::DICompositeType *
1352
1351
createUnsubstitutedVariantType (DebugTypeInfo DbgTy, EnumDecl *Decl,
1353
- StringRef MangledName, unsigned AlignInBits,
1352
+ StringRef MangledName,
1353
+ unsigned SizeInBits, unsigned AlignInBits,
1354
1354
llvm::DIScope *Scope, llvm::DIFile *File,
1355
1355
unsigned Line, llvm::DINode::DIFlags Flags) {
1356
1356
assert (!Decl->getRawType () &&
1357
1357
" Attempting to create variant debug info from raw enum!" );
1358
1358
1359
1359
StringRef Name = Decl->getName ().str ();
1360
- unsigned SizeInBits = DbgTy.getRawSizeInBits ().value_or (0 );
1361
1360
auto NumExtraInhabitants = DbgTy.getNumExtraInhabitants ();
1362
1361
1363
1362
// A variant part should actually be a child to a DW_TAG_structure_type
@@ -1419,8 +1418,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1419
1418
1420
1419
llvm::DIType *getOrCreateDesugaredType (Type Ty, DebugTypeInfo DbgTy) {
1421
1420
DebugTypeInfo BlandDbgTy (Ty, DbgTy.getFragmentStorageType (),
1422
- DbgTy.getRawSizeInBits (), DbgTy.getAlignment (),
1423
- DbgTy.hasDefaultAlignment (),
1421
+ DbgTy.getAlignment (), DbgTy.hasDefaultAlignment (),
1424
1422
DbgTy.isMetadataType (), DbgTy.isSizeFragmentSize (),
1425
1423
DbgTy.isFixedBuffer ());
1426
1424
return getOrCreateType (BlandDbgTy);
@@ -1687,11 +1685,12 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1687
1685
// emitting the storage size of the struct, but it may be necessary
1688
1686
// to emit the (target!) size of the underlying basic type.
1689
1687
uint64_t SizeOfByte = CI.getTargetInfo ().getCharWidth ();
1690
- // FIXME: SizeInBits is redundant with DbgTy, remove it.
1691
- auto *llvmty = IGM.getStorageTypeForUnlowered (DbgTy.getType ());
1688
+ auto CompletedDbgTy = CompletedDebugTypeInfo::getFromTypeInfo (
1689
+ DbgTy. getType (), IGM.getTypeInfoForUnlowered (DbgTy.getType ()), IGM );
1692
1690
std::optional<uint64_t > SizeInBitsOrNull;
1693
- if (llvmty->isSized ())
1694
- SizeInBitsOrNull = IGM.DataLayout .getTypeSizeInBits (llvmty);
1691
+ if (CompletedDbgTy)
1692
+ SizeInBitsOrNull = CompletedDbgTy->getSizeInBits ();
1693
+
1695
1694
uint64_t SizeInBits = SizeInBitsOrNull.value_or (0 );
1696
1695
unsigned AlignInBits = DbgTy.hasDefaultAlignment ()
1697
1696
? 0
@@ -1720,14 +1719,14 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1720
1719
case TypeKind::BuiltinPackIndex:
1721
1720
case TypeKind::BuiltinInteger: {
1722
1721
Encoding = llvm::dwarf::DW_ATE_unsigned;
1723
- if (auto CompletedDbgTy = CompletedDebugTypeInfo::get (DbgTy) )
1722
+ if (CompletedDbgTy)
1724
1723
SizeInBits = getSizeOfBasicType (*CompletedDbgTy);
1725
1724
break ;
1726
1725
}
1727
1726
1728
1727
case TypeKind::BuiltinIntegerLiteral: {
1729
1728
Encoding = llvm::dwarf::DW_ATE_unsigned; // ?
1730
- if (auto CompletedDbgTy = CompletedDebugTypeInfo::get (DbgTy) )
1729
+ if (CompletedDbgTy)
1731
1730
SizeInBits = getSizeOfBasicType (*CompletedDbgTy);
1732
1731
break ;
1733
1732
}
@@ -2015,7 +2014,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
2015
2014
auto L = getFileAndLocation (Decl);
2016
2015
unsigned FwdDeclLine = 0 ;
2017
2016
if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes)
2018
- if (auto CompletedDbgTy = CompletedDebugTypeInfo::get (DbgTy) )
2017
+ if (CompletedDbgTy)
2019
2018
return createEnumType (*CompletedDbgTy, Decl, MangledName, AlignInBits,
2020
2019
Scope, L.File , L.Line , Flags);
2021
2020
return createOpaqueStruct (Scope, Decl->getName ().str (), L.File ,
@@ -2041,8 +2040,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
2041
2040
UnsubstitutedTy->mapTypeOutOfContext (), {});
2042
2041
if (DeclTypeMangledName == MangledName) {
2043
2042
return createUnsubstitutedVariantType (DbgTy, Decl, MangledName,
2044
- AlignInBits, Scope, File, FwdDeclLine ,
2045
- Flags);
2043
+ SizeInBits, AlignInBits, Scope, File,
2044
+ FwdDeclLine, Flags);
2046
2045
}
2047
2046
// Force the creation of the unsubstituted type, don't create it
2048
2047
// directly so it goes through all the caching/verification logic.
@@ -2095,7 +2094,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
2095
2094
// For TypeAlias types, the DeclContext for the aliased type is
2096
2095
// in the decl of the alias type.
2097
2096
DebugTypeInfo AliasedDbgTy (
2098
- AliasedTy, DbgTy.getFragmentStorageType (), DbgTy. getRawSizeInBits (),
2097
+ AliasedTy, DbgTy.getFragmentStorageType (),
2099
2098
DbgTy.getAlignment (), DbgTy.hasDefaultAlignment (), false ,
2100
2099
DbgTy.isSizeFragmentSize (), DbgTy.isFixedBuffer (),
2101
2100
DbgTy.getNumExtraInhabitants ());
@@ -2190,10 +2189,11 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
2190
2189
bool sanityCheckCachedType (DebugTypeInfo DbgTy, llvm::DIType *CachedType) {
2191
2190
if (DbgTy.isForwardDecl ())
2192
2191
return true ;
2193
- auto *StorageType = IGM.getStorageTypeForUnlowered (DbgTy.getType ());
2192
+ auto CompletedDbgTy = CompletedDebugTypeInfo::getFromTypeInfo (
2193
+ DbgTy.getType (), IGM.getTypeInfoForUnlowered (DbgTy.getType ()), IGM);
2194
2194
std::optional<uint64_t > SizeInBits;
2195
- if (StorageType-> isSized () )
2196
- SizeInBits = IGM. DataLayout . getTypeSizeInBits (StorageType );
2195
+ if (CompletedDbgTy )
2196
+ SizeInBits = CompletedDbgTy-> getSizeInBits ( );
2197
2197
unsigned CachedSizeInBits = getSizeInBits (CachedType);
2198
2198
if ((SizeInBits && CachedSizeInBits != *SizeInBits) ||
2199
2199
(!SizeInBits && CachedSizeInBits)) {
0 commit comments