@@ -845,12 +845,12 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
845
845
return cast<llvm::DIFile>(Scope);
846
846
}
847
847
848
- static Size getStorageSize (const llvm::DataLayout &DL,
849
- ArrayRef<llvm::Value *> Storage) {
850
- unsigned size = 0 ;
848
+ static unsigned getStorageSizeInBits (const llvm::DataLayout &DL,
849
+ ArrayRef<llvm::Value *> Storage) {
850
+ unsigned SizeInBits = 0 ;
851
851
for (llvm::Value *Piece : Storage)
852
- size += DL.getTypeSizeInBits (Piece->getType ());
853
- return Size (size) ;
852
+ SizeInBits += DL.getTypeSizeInBits (Piece->getType ());
853
+ return SizeInBits ;
854
854
}
855
855
856
856
StringRef getMangledName (DebugTypeInfo DbgTy) {
@@ -948,10 +948,9 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
948
948
llvm::DINode::DIFlags Flags) {
949
949
unsigned SizeOfByte = CI.getTargetInfo ().getCharWidth ();
950
950
auto *Ty = getOrCreateType (DbgTy);
951
- auto *DITy = DBuilder.createMemberType (
952
- Scope, Name, File, 0 ,
953
- SizeOfByte * DbgTy.getSizeValue (), 0 , OffsetInBits,
954
- Flags, Ty);
951
+ auto *DITy =
952
+ DBuilder.createMemberType (Scope, Name, File, 0 , DbgTy.getSizeInBits (),
953
+ 0 , OffsetInBits, Flags, Ty);
955
954
OffsetInBits += getSizeInBits (Ty);
956
955
OffsetInBits = llvm::alignTo (OffsetInBits,
957
956
SizeOfByte * DbgTy.getAlignment ().getValue ());
@@ -1017,8 +1016,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1017
1016
llvm::DIFile *File, unsigned Line,
1018
1017
llvm::DINode::DIFlags Flags) {
1019
1018
StringRef Name = Decl->getName ().str ();
1020
- unsigned SizeOfByte = CI.getTargetInfo ().getCharWidth ();
1021
- unsigned SizeInBits = DbgTy.getSizeValue () * SizeOfByte;
1019
+ unsigned SizeInBits = DbgTy.getSizeInBits ();
1022
1020
// Default, since Swift doesn't allow specifying a custom alignment.
1023
1021
unsigned AlignInBits = 0 ;
1024
1022
@@ -1050,8 +1048,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1050
1048
// the storage size from the enum.
1051
1049
ElemDbgTy = CompletedDebugTypeInfo::get (
1052
1050
DebugTypeInfo (Decl->getRawType (), DbgTy.getFragmentStorageType (),
1053
- DbgTy.getRawSize (), DbgTy.getAlignment (), true , false ,
1054
- DbgTy.isSizeFragmentSize ()));
1051
+ DbgTy.getRawSizeInBits (), DbgTy.getAlignment (), true ,
1052
+ false , DbgTy.isSizeFragmentSize ()));
1055
1053
else if (auto ArgTy = ElemDecl->getArgumentInterfaceType ()) {
1056
1054
// A discriminated union. This should really be described as a
1057
1055
// DW_TAG_variant_type. For now only describing the data.
@@ -1089,15 +1087,14 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1089
1087
1090
1088
llvm::DIType *getOrCreateDesugaredType (Type Ty, DebugTypeInfo DbgTy) {
1091
1089
DebugTypeInfo BlandDbgTy (
1092
- Ty, DbgTy.getFragmentStorageType (), DbgTy.getRawSize (),
1090
+ Ty, DbgTy.getFragmentStorageType (), DbgTy.getRawSizeInBits (),
1093
1091
DbgTy.getAlignment (), DbgTy.hasDefaultAlignment (),
1094
1092
DbgTy.isMetadataType (), DbgTy.isSizeFragmentSize ());
1095
1093
return getOrCreateType (BlandDbgTy);
1096
1094
}
1097
1095
1098
1096
uint64_t getSizeOfBasicType (CompletedDebugTypeInfo DbgTy) {
1099
- uint64_t SizeOfByte = CI.getTargetInfo ().getCharWidth ();
1100
- uint64_t BitWidth = DbgTy.getSizeValue () * SizeOfByte;
1097
+ uint64_t BitWidth = DbgTy.getSizeInBits ();
1101
1098
llvm::Type *StorageType = DbgTy.getFragmentStorageType ()
1102
1099
? DbgTy.getFragmentStorageType ()
1103
1100
: IGM.DataLayout .getSmallestLegalIntType (
@@ -1332,8 +1329,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1332
1329
uint64_t SizeOfByte = CI.getTargetInfo ().getCharWidth ();
1333
1330
// FIXME: SizeInBits is redundant with DbgTy, remove it.
1334
1331
uint64_t SizeInBits = 0 ;
1335
- if (DbgTy.getTypeSize ())
1336
- SizeInBits = DbgTy.getTypeSize ()-> getValue () * SizeOfByte ;
1332
+ if (DbgTy.getTypeSizeInBits ())
1333
+ SizeInBits = * DbgTy.getTypeSizeInBits () ;
1337
1334
unsigned AlignInBits = DbgTy.hasDefaultAlignment ()
1338
1335
? 0
1339
1336
: DbgTy.getAlignment ().getValue () * SizeOfByte;
@@ -1448,7 +1445,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1448
1445
SizeInBits, AlignInBits, Flags, nullptr ,
1449
1446
llvm::dwarf::DW_LANG_Swift, MangledName);
1450
1447
StringRef Name = Decl->getName ().str ();
1451
- if (DbgTy.getTypeSize ())
1448
+ if (DbgTy.getTypeSizeInBits ())
1452
1449
return createOpaqueStruct (Scope, Name, File, FwdDeclLine, SizeInBits,
1453
1450
AlignInBits, Flags, MangledName);
1454
1451
return DBuilder.createForwardDecl (
@@ -1688,7 +1685,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1688
1685
// For TypeAlias types, the DeclContext for the aliased type is
1689
1686
// in the decl of the alias type.
1690
1687
DebugTypeInfo AliasedDbgTy (AliasedTy, DbgTy.getFragmentStorageType (),
1691
- DbgTy.getRawSize (), DbgTy.getAlignment (),
1688
+ DbgTy.getRawSizeInBits (), DbgTy.getAlignment (),
1692
1689
DbgTy.hasDefaultAlignment (), false ,
1693
1690
DbgTy.isSizeFragmentSize ());
1694
1691
return DBuilder.createTypedef (getOrCreateType (AliasedDbgTy), MangledName,
@@ -1783,9 +1780,16 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1783
1780
if (auto *DITy = getTypeOrNull (DbgTy.getType ())) {
1784
1781
// FIXME: Enable this assertion.
1785
1782
#if SWIFT_DEBUGINFO_CACHE_VERIFICATION
1786
- if (auto CachedSize = DbgTy.getTypeSize ()) {
1787
- if (unsigned Size = getSizeInBits (DITy))
1788
- assert (llvm::alignTo (Size, 8 ) / 8 == CachedSize->getValue ());
1783
+ if (auto CachedSizeInBits = DbgTy.getTypeSizeInBits ()) {
1784
+ if (unsigned SizeInBits = getSizeInBits (DITy)) {
1785
+ if (SizeInBits != *CachedSizeInBits) {
1786
+ DITy->dump ();
1787
+ DbgTy.dump ();
1788
+ llvm::errs () << " SizeInBits = " << SizeInBits << " \n " ;
1789
+ llvm::errs () << " CachedSizeInBits = " << *CachedSizeInBits << " \n " ;
1790
+ }
1791
+ assert (SizeInBits == *CachedSizeInBits);
1792
+ }
1789
1793
}
1790
1794
#endif
1791
1795
return DITy;
@@ -2530,8 +2534,8 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
2530
2534
if (DbgTy.getType ()->hasOpenedExistential ())
2531
2535
return ;
2532
2536
2533
- if (!DbgTy.getTypeSize ())
2534
- DbgTy.setSize ( getStorageSize (IGM.DataLayout , Storage));
2537
+ if (!DbgTy.getTypeSizeInBits ())
2538
+ DbgTy.setSizeInBits ( getStorageSizeInBits (IGM.DataLayout , Storage));
2535
2539
2536
2540
auto *Scope = dyn_cast_or_null<llvm::DILocalScope>(getOrCreateScope (DS));
2537
2541
assert (Scope && " variable has no local scope" );
0 commit comments