@@ -151,22 +151,29 @@ irgen::getTypeAndGenericSignatureForManglingOutlineFunction(SILType type) {
151
151
}
152
152
153
153
bool TypeInfo::withWitnessableMetadataCollector (
154
- IRGenFunction &IGF, SILType T, LayoutIsNeeded_t needsLayout ,
154
+ IRGenFunction &IGF, SILType T, LayoutIsNeeded_t mayNeedLayout ,
155
155
DeinitIsNeeded_t needsDeinit,
156
156
llvm::function_ref<void (OutliningMetadataCollector &)> invocation) const {
157
+ bool needsCollector = false ;
158
+ LayoutIsNeeded_t needsLayout = LayoutIsNotNeeded;
157
159
if (!T.hasLocalArchetype () &&
158
160
!IGF.outliningCanCallValueWitnesses ()) {
159
- OutliningMetadataCollector collector (IGF, needsLayout, needsDeinit) ;
161
+ needsCollector = true ;
160
162
if (T.hasArchetype ()) {
161
- collectMetadataForOutlining (collector, T) ;
163
+ needsLayout = LayoutIsNeeded ;
162
164
}
163
- invocation (collector);
164
- return true ;
165
+ } else if (!T.hasArchetype ()) {
166
+ needsCollector = true ;
167
+ // The implementation will call vwt in this case.
168
+ needsLayout = LayoutIsNotNeeded;
165
169
}
166
170
167
- if (!T.hasArchetype ()) {
168
- // The implementation will call vwt in this case.
171
+ if (needsCollector) {
169
172
OutliningMetadataCollector collector (IGF, needsLayout, needsDeinit);
173
+ if (needsDeinit || needsLayout) {
174
+ // Only collect if anything would be collected.
175
+ collectMetadataForOutlining (collector, T);
176
+ }
170
177
invocation (collector);
171
178
return true ;
172
179
}
@@ -198,10 +205,8 @@ void TypeInfo::callOutlinedCopy(IRGenFunction &IGF, Address dest, Address src,
198
205
}
199
206
200
207
void OutliningMetadataCollector::emitCallToOutlinedCopy (
201
- Address dest, Address src,
202
- SILType T, const TypeInfo &ti,
203
- IsInitialization_t isInit, IsTake_t isTake) const {
204
- assert (needsLayout);
208
+ Address dest, Address src, SILType T, const TypeInfo &ti,
209
+ IsInitialization_t isInit, IsTake_t isTake) const {
205
210
assert (!needsDeinit);
206
211
llvm::SmallVector<llvm::Value *, 4 > args;
207
212
args.push_back (IGF.Builder .CreateElementBitCast (src, ti.getStorageType ())
@@ -387,8 +392,7 @@ void TypeInfo::callOutlinedDestroy(IRGenFunction &IGF,
387
392
}
388
393
389
394
void OutliningMetadataCollector::emitCallToOutlinedDestroy (
390
- Address addr, SILType T, const TypeInfo &ti) const {
391
- assert (needsLayout);
395
+ Address addr, SILType T, const TypeInfo &ti) const {
392
396
assert (needsDeinit);
393
397
llvm::SmallVector<llvm::Value *, 4 > args;
394
398
args.push_back (IGF.Builder .CreateElementBitCast (addr, ti.getStorageType ())
0 commit comments