@@ -1689,7 +1689,10 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1689
1689
uint64_t SizeOfByte = CI.getTargetInfo ().getCharWidth ();
1690
1690
// FIXME: SizeInBits is redundant with DbgTy, remove it.
1691
1691
auto *llvmty = IGM.getStorageTypeForUnlowered (DbgTy.getType ());
1692
- uint64_t SizeInBits = llvmty->isSized () ? IGM.DataLayout .getTypeSizeInBits (llvmty) : 0 ;
1692
+ std::optional<uint64_t > SizeInBitsOrNull;
1693
+ if (llvmty->isSized ())
1694
+ SizeInBitsOrNull = IGM.DataLayout .getTypeSizeInBits (llvmty);
1695
+ uint64_t SizeInBits = SizeInBitsOrNull.value_or (0 );
1693
1696
unsigned AlignInBits = DbgTy.hasDefaultAlignment ()
1694
1697
? 0
1695
1698
: DbgTy.getAlignment ().getValue () * SizeOfByte;
@@ -1790,7 +1793,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1790
1793
SizeInBits, AlignInBits, Flags, nullptr ,
1791
1794
llvm::dwarf::DW_LANG_Swift, MangledName);
1792
1795
StringRef Name = Decl->getName ().str ();
1793
- if (!DbgTy. getTypeSizeInBits () )
1796
+ if (!SizeInBitsOrNull )
1794
1797
return DBuilder.createForwardDecl (
1795
1798
llvm::dwarf::DW_TAG_structure_type, MangledName, Scope, L.File ,
1796
1799
FwdDeclLine, llvm::dwarf::DW_LANG_Swift, 0 , AlignInBits);
@@ -2187,7 +2190,10 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
2187
2190
bool sanityCheckCachedType (DebugTypeInfo DbgTy, llvm::DIType *CachedType) {
2188
2191
if (DbgTy.isForwardDecl ())
2189
2192
return true ;
2190
- auto SizeInBits = DbgTy.getTypeSizeInBits ();
2193
+ auto *StorageType = IGM.getStorageTypeForUnlowered (DbgTy.getType ());
2194
+ std::optional<uint64_t > SizeInBits;
2195
+ if (StorageType->isSized ())
2196
+ SizeInBits = IGM.DataLayout .getTypeSizeInBits (StorageType);
2191
2197
unsigned CachedSizeInBits = getSizeInBits (CachedType);
2192
2198
if ((SizeInBits && CachedSizeInBits != *SizeInBits) ||
2193
2199
(!SizeInBits && CachedSizeInBits)) {
0 commit comments