@@ -552,8 +552,12 @@ class ArgumentInitHelper {
552552 substFormalParams.push_back (
553553 pd->toFunctionParam (pd->getType ()).getCanonical (nullptr ));
554554 };
555- for (auto paramDecl : *paramList) { addParamDecl (paramDecl); }
556- if (selfParam) { addParamDecl (selfParam); }
555+ for (auto paramDecl : *paramList) {
556+ addParamDecl (paramDecl);
557+ }
558+ if (selfParam) {
559+ addParamDecl (selfParam);
560+ }
557561
558562 // Initialize the formal parameter generator. Note that this can
559563 // immediately claim lowered parameters.
@@ -795,8 +799,32 @@ class ArgumentInitHelper {
795799 loc, value, MarkMustCheckInst::CheckKind::NoConsumeOrAssign);
796800 }
797801 } else {
798- assert (isa<MarkMustCheckInst>(value) &&
799- " Should have inserted mark must check inst in EmitBBArgs" );
802+ if (auto *fArg = dyn_cast<SILFunctionArgument>(value)) {
803+ switch (fArg ->getArgumentConvention ()) {
804+ case SILArgumentConvention::Direct_Guaranteed:
805+ case SILArgumentConvention::Direct_Owned:
806+ case SILArgumentConvention::Direct_Unowned:
807+ case SILArgumentConvention::Indirect_Inout:
808+ case SILArgumentConvention::Indirect_Out:
809+ case SILArgumentConvention::Indirect_InoutAliasable:
810+ case SILArgumentConvention::Pack_Inout:
811+ case SILArgumentConvention::Pack_Guaranteed:
812+ case SILArgumentConvention::Pack_Owned:
813+ case SILArgumentConvention::Pack_Out:
814+ llvm_unreachable (" Should have been handled elsewhere" );
815+ case SILArgumentConvention::Indirect_In:
816+ value = SGF.B .createMarkMustCheckInst (
817+ loc, value,
818+ MarkMustCheckInst::CheckKind::ConsumableAndAssignable);
819+ break ;
820+ case SILArgumentConvention::Indirect_In_Guaranteed:
821+ value = SGF.B .createMarkMustCheckInst (
822+ loc, value, MarkMustCheckInst::CheckKind::NoConsumeOrAssign);
823+ }
824+ } else {
825+ assert (isa<MarkMustCheckInst>(value) &&
826+ " Should have inserted mark must check inst in EmitBBArgs" );
827+ }
800828 }
801829 break ;
802830 case ValueOwnership::InOut:
0 commit comments