24
24
using namespace swift ;
25
25
using namespace irgen ;
26
26
27
- DebugTypeInfo::DebugTypeInfo (swift::Type Ty, llvm::Type *StorageTy ,
27
+ DebugTypeInfo::DebugTypeInfo (swift::Type Ty, llvm::Type *FragmentStorageTy ,
28
28
Optional<Size> size, Alignment align,
29
- bool HasDefaultAlignment, bool IsMetadata)
30
- : Type(Ty.getPointer()), StorageType(StorageTy), size(size), align(align),
31
- DefaultAlignment(HasDefaultAlignment), IsMetadataType(IsMetadata) {
29
+ bool HasDefaultAlignment, bool IsMetadata,
30
+ bool SizeIsFragmentSize)
31
+ : Type(Ty.getPointer()), FragmentStorageType(FragmentStorageTy), size(size),
32
+ align(align), DefaultAlignment(HasDefaultAlignment),
33
+ IsMetadataType(IsMetadata), SizeIsFragmentSize(SizeIsFragmentSize) {
32
34
assert (align.getValue () != 0 );
33
35
}
34
36
@@ -42,7 +44,8 @@ static bool hasDefaultAlignment(swift::Type Ty) {
42
44
}
43
45
44
46
DebugTypeInfo DebugTypeInfo::getFromTypeInfo (swift::Type Ty,
45
- const TypeInfo &Info) {
47
+ const TypeInfo &Info,
48
+ bool IsFragmentTypeInfo) {
46
49
Optional<Size> size;
47
50
if (Info.isFixedSize ()) {
48
51
const FixedTypeInfo &FixTy = *cast<const FixedTypeInfo>(&Info);
@@ -51,11 +54,12 @@ DebugTypeInfo DebugTypeInfo::getFromTypeInfo(swift::Type Ty,
51
54
assert (Info.getStorageType () && " StorageType is a nullptr" );
52
55
return DebugTypeInfo (Ty.getPointer (), Info.getStorageType (), size,
53
56
Info.getBestKnownAlignment (), ::hasDefaultAlignment (Ty),
54
- false );
57
+ false , IsFragmentTypeInfo );
55
58
}
56
59
57
60
DebugTypeInfo DebugTypeInfo::getLocalVariable (VarDecl *Decl, swift::Type Ty,
58
- const TypeInfo &Info) {
61
+ const TypeInfo &Info,
62
+ bool IsFragmentTypeInfo) {
59
63
60
64
auto DeclType = Decl->getInterfaceType ();
61
65
auto RealType = Ty;
@@ -69,30 +73,32 @@ DebugTypeInfo DebugTypeInfo::getLocalVariable(VarDecl *Decl, swift::Type Ty,
69
73
// the type hasn't been mucked with by an optimization pass.
70
74
auto *Type = Sugared->isEqual (RealType) ? DeclType.getPointer ()
71
75
: RealType.getPointer ();
72
- return getFromTypeInfo (Type, Info);
76
+ return getFromTypeInfo (Type, Info, IsFragmentTypeInfo );
73
77
}
74
78
75
79
DebugTypeInfo DebugTypeInfo::getMetadata (swift::Type Ty, llvm::Type *StorageTy,
76
80
Size size, Alignment align) {
77
81
DebugTypeInfo DbgTy (Ty.getPointer (), StorageTy, size,
78
- align, true , false );
82
+ align, true , false , false );
79
83
assert (StorageTy && " StorageType is a nullptr" );
80
- assert (!DbgTy.isContextArchetype () && " type metadata cannot contain an archetype" );
84
+ assert (!DbgTy.isContextArchetype () &&
85
+ " type metadata cannot contain an archetype" );
81
86
return DbgTy;
82
87
}
83
88
84
89
DebugTypeInfo DebugTypeInfo::getArchetype (swift::Type Ty, llvm::Type *StorageTy,
85
90
Size size, Alignment align) {
86
91
DebugTypeInfo DbgTy (Ty.getPointer (), StorageTy, size,
87
- align, true , true );
92
+ align, true , true , false );
88
93
assert (StorageTy && " StorageType is a nullptr" );
89
- assert (!DbgTy.isContextArchetype () && " type metadata cannot contain an archetype" );
94
+ assert (!DbgTy.isContextArchetype () &&
95
+ " type metadata cannot contain an archetype" );
90
96
return DbgTy;
91
97
}
92
98
93
99
DebugTypeInfo DebugTypeInfo::getForwardDecl (swift::Type Ty) {
94
100
DebugTypeInfo DbgTy (Ty.getPointer (), nullptr , {}, Alignment (1 ), true ,
95
- false );
101
+ false , false );
96
102
return DbgTy;
97
103
}
98
104
@@ -109,29 +115,30 @@ DebugTypeInfo DebugTypeInfo::getGlobal(SILGlobalVariable *GV,
109
115
Type = DeclType.getPointer ();
110
116
}
111
117
DebugTypeInfo DbgTy (Type, StorageTy, size, align, ::hasDefaultAlignment (Type),
112
- false );
113
- assert (StorageTy && " StorageType is a nullptr" );
118
+ false , false );
119
+ assert (StorageTy && " FragmentStorageType is a nullptr" );
114
120
assert (!DbgTy.isContextArchetype () &&
115
121
" type of global variable cannot be an archetype" );
116
122
assert (align.getValue () != 0 );
117
123
return DbgTy;
118
124
}
119
125
120
126
DebugTypeInfo DebugTypeInfo::getObjCClass (ClassDecl *theClass,
121
- llvm::Type *StorageType, Size size,
122
- Alignment align) {
123
- DebugTypeInfo DbgTy (theClass->getInterfaceType ().getPointer (), StorageType,
124
- size, align, true , false );
125
- assert (StorageType && " StorageType is a nullptr" );
126
- assert (!DbgTy.isContextArchetype () && " type of objc class cannot be an archetype" );
127
+ llvm::Type *FragmentStorageType,
128
+ Size size, Alignment align) {
129
+ DebugTypeInfo DbgTy (theClass->getInterfaceType ().getPointer (),
130
+ FragmentStorageType, size, align, true , false , false );
131
+ assert (FragmentStorageType && " FragmentStorageType is a nullptr" );
132
+ assert (!DbgTy.isContextArchetype () &&
133
+ " type of objc class cannot be an archetype" );
127
134
return DbgTy;
128
135
}
129
136
130
137
DebugTypeInfo DebugTypeInfo::getErrorResult (swift::Type Ty,
131
138
llvm::Type *StorageType, Size size,
132
139
Alignment align) {
133
- assert (StorageType && " StorageType is a nullptr" );
134
- return {Ty, StorageType, size, align, true , false };
140
+ assert (StorageType && " FragmentStorageType is a nullptr" );
141
+ return {Ty, StorageType, size, align, true , false , false };
135
142
}
136
143
137
144
bool DebugTypeInfo::operator ==(DebugTypeInfo T) const {
@@ -162,9 +169,9 @@ LLVM_DUMP_METHOD void DebugTypeInfo::dump() const {
162
169
llvm::errs () << " Alignment " << align.getValue () << " ] " ;
163
170
getType ()->dump (llvm::errs ());
164
171
165
- if (StorageType ) {
166
- llvm::errs () << " StorageType =" ;
167
- StorageType ->dump ();
172
+ if (FragmentStorageType ) {
173
+ llvm::errs () << " FragmentStorageType =" ;
174
+ FragmentStorageType ->dump ();
168
175
} else
169
176
llvm::errs () << " forward-declared\n " ;
170
177
}
0 commit comments