@@ -284,6 +284,16 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
284284 super::visitCopyValueInst (Copy);
285285 }
286286
287+ void visitExplicitCopyValueInst (ExplicitCopyValueInst *Copy) {
288+ // If the substituted type is trivial, ignore the copy.
289+ SILType copyTy = getOpType (Copy->getType ());
290+ if (copyTy.isTrivial (*Copy->getFunction ())) {
291+ recordFoldedValue (SILValue (Copy), getOpValue (Copy->getOperand ()));
292+ return ;
293+ }
294+ super::visitExplicitCopyValueInst (Copy);
295+ }
296+
287297 void visitDestroyValueInst (DestroyValueInst *Destroy) {
288298 // If the substituted type is trivial, ignore the destroy.
289299 SILType destroyTy = getOpType (Destroy->getOperand ()->getType ());
@@ -293,6 +303,24 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
293303 super::visitDestroyValueInst (Destroy);
294304 }
295305
306+ void visitEndLifetimeInst (EndLifetimeInst *endLifetime) {
307+ // If the substituted type is trivial, ignore the end_lifetime.
308+ SILType ty = getOpType (endLifetime->getOperand ()->getType ());
309+ if (ty.isTrivial (*endLifetime->getFunction ())) {
310+ return ;
311+ }
312+ super::visitEndLifetimeInst (endLifetime);
313+ }
314+
315+ void visitExtendLifetimeInst (ExtendLifetimeInst *extendLifetime) {
316+ // If the substituted type is trivial, ignore the extend_lifetime.
317+ SILType ty = getOpType (extendLifetime->getOperand ()->getType ());
318+ if (ty.isTrivial (*extendLifetime->getFunction ())) {
319+ return ;
320+ }
321+ super::visitExtendLifetimeInst (extendLifetime);
322+ }
323+
296324 void visitDifferentiableFunctionExtractInst (
297325 DifferentiableFunctionExtractInst *dfei) {
298326 // If the extractee is the original function, do regular cloning.
0 commit comments