@@ -135,24 +135,35 @@ irgen::getTypeAndGenericSignatureForManglingOutlineFunction(SILType type) {
135135 env->getGenericSignature ().getCanonicalSignature ()};
136136}
137137
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 {
141141 if (!T.hasLocalArchetype () &&
142142 !IGF.outliningCanCallValueWitnesses ()) {
143143 OutliningMetadataCollector collector (IGF);
144144 if (T.hasArchetype ()) {
145145 collectMetadataForOutlining (collector, T);
146146 }
147- collector. emitCallToOutlinedCopy (dest, src, T, * this , isInit, isTake );
148- return ;
147+ invocation (collector );
148+ return true ;
149149 }
150150
151151 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.
154153 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+ })) {
156167 return ;
157168 }
158169
@@ -345,21 +356,9 @@ void TypeInfo::callOutlinedDestroy(IRGenFunction &IGF,
345356 if (IGF.IGM .getTypeLowering (T).isTrivial ())
346357 return ;
347358
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+ })) {
363362 return ;
364363 }
365364
0 commit comments