@@ -1044,11 +1044,10 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
10441044 llvm::DINode::DIFlags Flags) {
10451045 unsigned SizeOfByte = CI.getTargetInfo ().getCharWidth ();
10461046 auto *Ty = getOrCreateType (DbgTy);
1047+ auto SizeInBits = getSizeInBits (Ty);
10471048 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;
10521051 OffsetInBits = llvm::alignTo (OffsetInBits,
10531052 SizeOfByte * DbgTy.getAlignment ().getValue ());
10541053 return DITy;
@@ -1350,14 +1349,14 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
13501349 // Create debug information for an enum with no raw type.
13511350 llvm::DICompositeType *
13521351 createUnsubstitutedVariantType (DebugTypeInfo DbgTy, EnumDecl *Decl,
1353- StringRef MangledName, unsigned AlignInBits,
1352+ StringRef MangledName,
1353+ unsigned SizeInBits, unsigned AlignInBits,
13541354 llvm::DIScope *Scope, llvm::DIFile *File,
13551355 unsigned Line, llvm::DINode::DIFlags Flags) {
13561356 assert (!Decl->getRawType () &&
13571357 " Attempting to create variant debug info from raw enum!" );
13581358
13591359 StringRef Name = Decl->getName ().str ();
1360- unsigned SizeInBits = DbgTy.getRawSizeInBits ().value_or (0 );
13611360 auto NumExtraInhabitants = DbgTy.getNumExtraInhabitants ();
13621361
13631362 // A variant part should actually be a child to a DW_TAG_structure_type
@@ -1419,8 +1418,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
14191418
14201419 llvm::DIType *getOrCreateDesugaredType (Type Ty, DebugTypeInfo DbgTy) {
14211420 DebugTypeInfo BlandDbgTy (Ty, DbgTy.getFragmentStorageType (),
1422- DbgTy.getRawSizeInBits (), DbgTy.getAlignment (),
1423- DbgTy.hasDefaultAlignment (),
1421+ DbgTy.getAlignment (), DbgTy.hasDefaultAlignment (),
14241422 DbgTy.isMetadataType (), DbgTy.isSizeFragmentSize (),
14251423 DbgTy.isFixedBuffer ());
14261424 return getOrCreateType (BlandDbgTy);
@@ -1687,11 +1685,12 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
16871685 // emitting the storage size of the struct, but it may be necessary
16881686 // to emit the (target!) size of the underlying basic type.
16891687 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 );
16921690 std::optional<uint64_t > SizeInBitsOrNull;
1693- if (llvmty->isSized ())
1694- SizeInBitsOrNull = IGM.DataLayout .getTypeSizeInBits (llvmty);
1691+ if (CompletedDbgTy)
1692+ SizeInBitsOrNull = CompletedDbgTy->getSizeInBits ();
1693+
16951694 uint64_t SizeInBits = SizeInBitsOrNull.value_or (0 );
16961695 unsigned AlignInBits = DbgTy.hasDefaultAlignment ()
16971696 ? 0
@@ -1720,14 +1719,14 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
17201719 case TypeKind::BuiltinPackIndex:
17211720 case TypeKind::BuiltinInteger: {
17221721 Encoding = llvm::dwarf::DW_ATE_unsigned;
1723- if (auto CompletedDbgTy = CompletedDebugTypeInfo::get (DbgTy) )
1722+ if (CompletedDbgTy)
17241723 SizeInBits = getSizeOfBasicType (*CompletedDbgTy);
17251724 break ;
17261725 }
17271726
17281727 case TypeKind::BuiltinIntegerLiteral: {
17291728 Encoding = llvm::dwarf::DW_ATE_unsigned; // ?
1730- if (auto CompletedDbgTy = CompletedDebugTypeInfo::get (DbgTy) )
1729+ if (CompletedDbgTy)
17311730 SizeInBits = getSizeOfBasicType (*CompletedDbgTy);
17321731 break ;
17331732 }
@@ -2015,7 +2014,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
20152014 auto L = getFileAndLocation (Decl);
20162015 unsigned FwdDeclLine = 0 ;
20172016 if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes)
2018- if (auto CompletedDbgTy = CompletedDebugTypeInfo::get (DbgTy) )
2017+ if (CompletedDbgTy)
20192018 return createEnumType (*CompletedDbgTy, Decl, MangledName, AlignInBits,
20202019 Scope, L.File , L.Line , Flags);
20212020 return createOpaqueStruct (Scope, Decl->getName ().str (), L.File ,
@@ -2041,8 +2040,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
20412040 UnsubstitutedTy->mapTypeOutOfContext (), {});
20422041 if (DeclTypeMangledName == MangledName) {
20432042 return createUnsubstitutedVariantType (DbgTy, Decl, MangledName,
2044- AlignInBits, Scope, File, FwdDeclLine ,
2045- Flags);
2043+ SizeInBits, AlignInBits, Scope, File,
2044+ FwdDeclLine, Flags);
20462045 }
20472046 // Force the creation of the unsubstituted type, don't create it
20482047 // directly so it goes through all the caching/verification logic.
@@ -2095,7 +2094,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
20952094 // For TypeAlias types, the DeclContext for the aliased type is
20962095 // in the decl of the alias type.
20972096 DebugTypeInfo AliasedDbgTy (
2098- AliasedTy, DbgTy.getFragmentStorageType (), DbgTy. getRawSizeInBits (),
2097+ AliasedTy, DbgTy.getFragmentStorageType (),
20992098 DbgTy.getAlignment (), DbgTy.hasDefaultAlignment (), false ,
21002099 DbgTy.isSizeFragmentSize (), DbgTy.isFixedBuffer (),
21012100 DbgTy.getNumExtraInhabitants ());
@@ -2190,10 +2189,11 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
21902189 bool sanityCheckCachedType (DebugTypeInfo DbgTy, llvm::DIType *CachedType) {
21912190 if (DbgTy.isForwardDecl ())
21922191 return true ;
2193- auto *StorageType = IGM.getStorageTypeForUnlowered (DbgTy.getType ());
2192+ auto CompletedDbgTy = CompletedDebugTypeInfo::getFromTypeInfo (
2193+ DbgTy.getType (), IGM.getTypeInfoForUnlowered (DbgTy.getType ()), IGM);
21942194 std::optional<uint64_t > SizeInBits;
2195- if (StorageType-> isSized () )
2196- SizeInBits = IGM. DataLayout . getTypeSizeInBits (StorageType );
2195+ if (CompletedDbgTy )
2196+ SizeInBits = CompletedDbgTy-> getSizeInBits ( );
21972197 unsigned CachedSizeInBits = getSizeInBits (CachedType);
21982198 if ((SizeInBits && CachedSizeInBits != *SizeInBits) ||
21992199 (!SizeInBits && CachedSizeInBits)) {
0 commit comments