@@ -135,24 +135,35 @@ irgen::getTypeAndGenericSignatureForManglingOutlineFunction(SILType type) {
135
135
env->getGenericSignature ().getCanonicalSignature ()};
136
136
}
137
137
138
- void TypeInfo::callOutlinedCopy (IRGenFunction &IGF, Address dest, Address src,
139
- SILType T, IsInitialization_t isInit ,
140
- IsTake_t isTake ) const {
138
+ bool TypeInfo::withMetadataCollector (
139
+ IRGenFunction &IGF, SILType T,
140
+ llvm::function_ref< void (OutliningMetadataCollector &)> invocation ) const {
141
141
if (!T.hasLocalArchetype () &&
142
142
!IGF.outliningCanCallValueWitnesses ()) {
143
143
OutliningMetadataCollector collector (IGF);
144
144
if (T.hasArchetype ()) {
145
145
collectMetadataForOutlining (collector, T);
146
146
}
147
- collector. emitCallToOutlinedCopy (dest, src, T, * this , isInit, isTake );
148
- return ;
147
+ invocation (collector );
148
+ return true ;
149
149
}
150
150
151
151
if (!T.hasArchetype ()) {
152
- // Call the outlined copy function (the implementation will call vwt in this
153
- // case).
152
+ // The implementation will call vwt in this case.
154
153
OutliningMetadataCollector collector (IGF);
155
- collector.emitCallToOutlinedCopy (dest, src, T, *this , isInit, isTake);
154
+ invocation (collector);
155
+ return true ;
156
+ }
157
+
158
+ return false ;
159
+ }
160
+
161
+ void TypeInfo::callOutlinedCopy (IRGenFunction &IGF, Address dest, Address src,
162
+ SILType T, IsInitialization_t isInit,
163
+ IsTake_t isTake) const {
164
+ if (withMetadataCollector (IGF, T, [&](auto collector) {
165
+ collector.emitCallToOutlinedCopy (dest, src, T, *this , isInit, isTake);
166
+ })) {
156
167
return ;
157
168
}
158
169
@@ -345,21 +356,9 @@ void TypeInfo::callOutlinedDestroy(IRGenFunction &IGF,
345
356
if (IGF.IGM .getTypeLowering (T).isTrivial ())
346
357
return ;
347
358
348
- if (!T.hasLocalArchetype () &&
349
- !IGF.outliningCanCallValueWitnesses ()) {
350
- OutliningMetadataCollector collector (IGF);
351
- if (T.hasArchetype ()) {
352
- collectMetadataForOutlining (collector, T);
353
- }
354
- collector.emitCallToOutlinedDestroy (addr, T, *this );
355
- return ;
356
- }
357
-
358
- if (!T.hasArchetype ()) {
359
- // Call the outlined copy function (the implementation will call vwt in this
360
- // case).
361
- OutliningMetadataCollector collector (IGF);
362
- collector.emitCallToOutlinedDestroy (addr, T, *this );
359
+ if (withMetadataCollector (IGF, T, [&](auto collector) {
360
+ collector.emitCallToOutlinedDestroy (addr, T, *this );
361
+ })) {
363
362
return ;
364
363
}
365
364
0 commit comments