@@ -26,16 +26,13 @@ using namespace swift;
26
26
using namespace irgen ;
27
27
28
28
DebugTypeInfo::DebugTypeInfo (swift::Type Ty, llvm::Type *FragmentStorageTy,
29
- std::optional<Size::int_type> SizeInBits,
30
29
Alignment Align, bool HasDefaultAlignment,
31
- bool IsMetadata, bool SizeIsFragmentSize,
32
- bool IsFixedBuffer,
30
+ bool IsMetadata, bool IsFixedBuffer,
33
31
std::optional<uint32_t > NumExtraInhabitants)
34
32
: Type(Ty.getPointer()), FragmentStorageType(FragmentStorageTy),
35
- SizeInBits(SizeInBits), NumExtraInhabitants(NumExtraInhabitants),
33
+ NumExtraInhabitants(NumExtraInhabitants),
36
34
Align(Align), DefaultAlignment(HasDefaultAlignment),
37
- IsMetadataType(IsMetadata), SizeIsFragmentSize(SizeIsFragmentSize),
38
- IsFixedBuffer(IsFixedBuffer) {
35
+ IsMetadataType(IsMetadata), IsFixedBuffer(IsFixedBuffer) {
39
36
assert (Align.getValue () != 0 );
40
37
}
41
38
@@ -50,32 +47,23 @@ static bool hasDefaultAlignment(swift::Type Ty) {
50
47
}
51
48
52
49
DebugTypeInfo DebugTypeInfo::getFromTypeInfo (swift::Type Ty, const TypeInfo &TI,
53
- IRGenModule &IGM,
54
- bool IsFragmentTypeInfo) {
55
- std::optional<Size::int_type> SizeInBits;
50
+ IRGenModule &IGM) {
56
51
llvm::Type *StorageType = TI.getStorageType ();
57
52
std::optional<uint32_t > NumExtraInhabitants;
58
- if (StorageType->isSized ())
59
- SizeInBits = IGM.DataLayout .getTypeSizeInBits (StorageType);
60
- else if (TI.isFixedSize ()) {
61
- const FixedTypeInfo &FixTy = *cast<const FixedTypeInfo>(&TI);
62
- Size::int_type Size = FixTy.getFixedSize ().getValue () * 8 ;
63
- SizeInBits = Size;
64
- }
65
53
if (TI.isFixedSize ()) {
66
54
const FixedTypeInfo &FixTy = *cast<const FixedTypeInfo>(&TI);
67
55
NumExtraInhabitants = FixTy.getFixedExtraInhabitantCount (IGM);
68
56
}
69
57
assert (TI.getStorageType () && " StorageType is a nullptr" );
70
- return DebugTypeInfo (Ty.getPointer (), StorageType, SizeInBits,
58
+ return DebugTypeInfo (Ty.getPointer (), StorageType,
71
59
TI.getBestKnownAlignment (), ::hasDefaultAlignment (Ty),
72
- false , IsFragmentTypeInfo, false , NumExtraInhabitants);
60
+ /* IsMetadataType = */ false ,
61
+ /* IsFixedBuffer = */ false , NumExtraInhabitants);
73
62
}
74
63
75
64
DebugTypeInfo DebugTypeInfo::getLocalVariable (VarDecl *Decl, swift::Type Ty,
76
65
const TypeInfo &Info,
77
- IRGenModule &IGM,
78
- bool IsFragmentTypeInfo) {
66
+ IRGenModule &IGM) {
79
67
80
68
auto DeclType = Decl->getInterfaceType ();
81
69
auto RealType = Ty;
@@ -89,14 +77,15 @@ DebugTypeInfo DebugTypeInfo::getLocalVariable(VarDecl *Decl, swift::Type Ty,
89
77
// the type hasn't been mucked with by an optimization pass.
90
78
auto *Type = Sugared->isEqual (RealType) ? DeclType.getPointer ()
91
79
: RealType.getPointer ();
92
- return getFromTypeInfo (Type, Info, IGM, IsFragmentTypeInfo );
80
+ return getFromTypeInfo (Type, Info, IGM);
93
81
}
94
82
95
83
DebugTypeInfo DebugTypeInfo::getGlobalMetadata (swift::Type Ty,
96
84
llvm::Type *StorageTy, Size size,
97
85
Alignment align) {
98
- DebugTypeInfo DbgTy (Ty.getPointer (), StorageTy, size.getValue () * 8 , align,
99
- true , false , false );
86
+ DebugTypeInfo DbgTy (Ty.getPointer (), StorageTy, align,
87
+ /* HasDefaultAlignment = */ true ,
88
+ /* IsMetadataType = */ false );
100
89
assert (StorageTy && " StorageType is a nullptr" );
101
90
assert (!DbgTy.isContextArchetype () &&
102
91
" type metadata cannot contain an archetype" );
@@ -106,8 +95,9 @@ DebugTypeInfo DebugTypeInfo::getGlobalMetadata(swift::Type Ty,
106
95
DebugTypeInfo DebugTypeInfo::getTypeMetadata (swift::Type Ty,
107
96
llvm::Type *StorageTy, Size size,
108
97
Alignment align) {
109
- DebugTypeInfo DbgTy (Ty.getPointer (), StorageTy, size.getValue () * 8 , align,
110
- true , true , false );
98
+ DebugTypeInfo DbgTy (Ty.getPointer (), StorageTy, align,
99
+ /* HasDefaultAlignment = */ true ,
100
+ /* IsMetadataType = */ true );
111
101
assert (StorageTy && " StorageType is a nullptr" );
112
102
assert (!DbgTy.isContextArchetype () &&
113
103
" type metadata cannot contain an archetype" );
@@ -132,7 +122,7 @@ DebugTypeInfo DebugTypeInfo::getGlobal(SILGlobalVariable *GV,
132
122
Type = DeclType.getPointer ();
133
123
}
134
124
auto &TI = IGM.getTypeInfoForUnlowered (Type);
135
- DebugTypeInfo DbgTy = getFromTypeInfo (Type, TI, IGM, false );
125
+ DebugTypeInfo DbgTy = getFromTypeInfo (Type, TI, IGM);
136
126
assert (FragmentStorageType && " FragmentStorageType is a nullptr" );
137
127
assert (!DbgTy.isContextArchetype () &&
138
128
" type of global variable cannot be an archetype" );
@@ -152,8 +142,9 @@ DebugTypeInfo::getGlobalFixedBuffer(SILGlobalVariable *GV,
152
142
if (DeclType->isEqual (LowTy))
153
143
Type = DeclType.getPointer ();
154
144
}
155
- DebugTypeInfo DbgTy (Type, FragmentStorageType, SizeInBytes.getValue () * 8 ,
156
- Align, ::hasDefaultAlignment (Type), false , false , true );
145
+ DebugTypeInfo DbgTy (Type, FragmentStorageType,
146
+ Align, ::hasDefaultAlignment (Type),
147
+ /* IsMetadataType = */ false , /* IsFixedBuffer = */ true );
157
148
assert (FragmentStorageType && " FragmentStorageType is a nullptr" );
158
149
assert (!DbgTy.isContextArchetype () &&
159
150
" type of global variable cannot be an archetype" );
@@ -164,8 +155,9 @@ DebugTypeInfo DebugTypeInfo::getObjCClass(ClassDecl *theClass,
164
155
llvm::Type *FragmentStorageType,
165
156
Size SizeInBytes, Alignment align) {
166
157
DebugTypeInfo DbgTy (theClass->getInterfaceType ().getPointer (),
167
- FragmentStorageType, SizeInBytes.getValue () * 8 , align,
168
- true , false , false );
158
+ FragmentStorageType, align,
159
+ /* HasDefaultAlignment = */ true ,
160
+ /* IsMetadataType = */ false );
169
161
assert (FragmentStorageType && " FragmentStorageType is a nullptr" );
170
162
assert (!DbgTy.isContextArchetype () &&
171
163
" type of objc class cannot be an archetype" );
@@ -175,13 +167,12 @@ DebugTypeInfo DebugTypeInfo::getObjCClass(ClassDecl *theClass,
175
167
DebugTypeInfo DebugTypeInfo::getErrorResult (swift::Type Ty,
176
168
IRGenModule &IGM) {
177
169
auto &TI = IGM.getTypeInfoForUnlowered (Ty);
178
- DebugTypeInfo DbgTy = getFromTypeInfo (Ty, TI, IGM, false );
170
+ DebugTypeInfo DbgTy = getFromTypeInfo (Ty, TI, IGM);
179
171
return DbgTy;
180
172
}
181
173
182
174
bool DebugTypeInfo::operator ==(DebugTypeInfo T) const {
183
175
return getType () == T.getType () &&
184
- SizeInBits == T.SizeInBits &&
185
176
Align == T.Align ;
186
177
}
187
178
@@ -204,8 +195,6 @@ TypeDecl *DebugTypeInfo::getDecl() const {
204
195
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
205
196
LLVM_DUMP_METHOD void DebugTypeInfo::dump () const {
206
197
llvm::errs () << " [" ;
207
- if (SizeInBits)
208
- llvm::errs () << " SizeInBits " << *SizeInBits << " " ;
209
198
llvm::errs () << " Alignment " << Align.getValue () << " ] " ;
210
199
if (auto *Type = getType ())
211
200
Type->dump (llvm::errs ());
@@ -217,3 +206,19 @@ LLVM_DUMP_METHOD void DebugTypeInfo::dump() const {
217
206
llvm::errs () << " forward-declared\n " ;
218
207
}
219
208
#endif
209
+
210
+ std::optional<CompletedDebugTypeInfo>
211
+ CompletedDebugTypeInfo::getFromTypeInfo (swift::Type Ty, const TypeInfo &Info, IRGenModule &IGM) {
212
+ auto *StorageType = IGM.getStorageTypeForUnlowered (Ty);
213
+ std::optional<uint64_t > SizeInBits;
214
+ if (StorageType->isSized ())
215
+ SizeInBits = IGM.DataLayout .getTypeSizeInBits (StorageType);
216
+ else if (Info.isFixedSize ()) {
217
+ const FixedTypeInfo &FixTy = *cast<const FixedTypeInfo>(&Info);
218
+ Size::int_type Size = FixTy.getFixedSize ().getValue () * 8 ;
219
+ SizeInBits = Size;
220
+ }
221
+
222
+ return CompletedDebugTypeInfo::get (
223
+ DebugTypeInfo::getFromTypeInfo (Ty, Info, IGM), SizeInBits);
224
+ }
0 commit comments