Skip to content

Commit 75015b5

Browse files
committed
[DebugInfo] Remove accessor for type size in DebugTypeInfo
1 parent 01c752e commit 75015b5

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/IRGen/DebugTypeInfo.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ class DebugTypeInfo {
110110
assert(FragmentStorageType && "only defined types may have a size");
111111
return FragmentStorageType;
112112
}
113-
std::optional<Size::int_type> getTypeSizeInBits() const {
114-
return SizeIsFragmentSize ? std::nullopt : SizeInBits;
115-
}
116113
std::optional<Size::int_type> getRawSizeInBits() const { return SizeInBits; }
117114
Alignment getAlignment() const { return Align; }
118115
bool isNull() const { return Type == nullptr; }

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,10 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
16891689
uint64_t SizeOfByte = CI.getTargetInfo().getCharWidth();
16901690
// FIXME: SizeInBits is redundant with DbgTy, remove it.
16911691
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);
16931696
unsigned AlignInBits = DbgTy.hasDefaultAlignment()
16941697
? 0
16951698
: DbgTy.getAlignment().getValue() * SizeOfByte;
@@ -1790,7 +1793,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
17901793
SizeInBits, AlignInBits, Flags, nullptr,
17911794
llvm::dwarf::DW_LANG_Swift, MangledName);
17921795
StringRef Name = Decl->getName().str();
1793-
if (!DbgTy.getTypeSizeInBits())
1796+
if (!SizeInBitsOrNull)
17941797
return DBuilder.createForwardDecl(
17951798
llvm::dwarf::DW_TAG_structure_type, MangledName, Scope, L.File,
17961799
FwdDeclLine, llvm::dwarf::DW_LANG_Swift, 0, AlignInBits);
@@ -2187,7 +2190,10 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
21872190
bool sanityCheckCachedType(DebugTypeInfo DbgTy, llvm::DIType *CachedType) {
21882191
if (DbgTy.isForwardDecl())
21892192
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);
21912197
unsigned CachedSizeInBits = getSizeInBits(CachedType);
21922198
if ((SizeInBits && CachedSizeInBits != *SizeInBits) ||
21932199
(!SizeInBits && CachedSizeInBits)) {

0 commit comments

Comments
 (0)