@@ -670,8 +670,10 @@ void ReabstractionInfo::createSubstitutedAndSpecializedTypes() {
670
670
// Check which parameters and results can be converted from
671
671
// indirect to direct ones.
672
672
NumFormalIndirectResults = SubstitutedType->getNumIndirectFormalResults ();
673
- Conversions.resize (NumFormalIndirectResults +
674
- SubstitutedType->getParameters ().size ());
673
+ unsigned NumArgs = NumFormalIndirectResults +
674
+ SubstitutedType->getParameters ().size ();
675
+ Conversions.resize (NumArgs);
676
+ TrivialArgs.resize (NumArgs);
675
677
676
678
CanGenericSignature CanSig;
677
679
if (SpecializedGenericSig)
@@ -696,6 +698,8 @@ void ReabstractionInfo::createSubstitutedAndSpecializedTypes() {
696
698
if (TL.isLoadable () && !RI.getReturnValueType (M, SubstitutedType)->isVoid () &&
697
699
shouldExpand (M, ResultTy)) {
698
700
Conversions.set (IdxForResult);
701
+ if (TL.isTrivial ())
702
+ TrivialArgs.set (IdxForResult);
699
703
break ;
700
704
}
701
705
++IdxForResult;
@@ -721,6 +725,8 @@ void ReabstractionInfo::createSubstitutedAndSpecializedTypes() {
721
725
case ParameterConvention::Indirect_In:
722
726
case ParameterConvention::Indirect_In_Guaranteed:
723
727
Conversions.set (IdxToInsert);
728
+ if (TL.isTrivial ())
729
+ TrivialArgs.set (IdxToInsert);
724
730
break ;
725
731
case ParameterConvention::Indirect_In_Constant:
726
732
case ParameterConvention::Indirect_Inout:
@@ -796,14 +802,12 @@ createSpecializedType(CanSILFunctionType SubstFTy, SILModule &M) const {
796
802
unsigned IndirectResultIdx = 0 ;
797
803
for (SILResultInfo RI : SubstFTy->getResults ()) {
798
804
if (RI.isFormalIndirect ()) {
805
+ bool isTrivial = TrivialArgs.test (IndirectResultIdx);
799
806
if (isFormalResultConverted (IndirectResultIdx++)) {
800
807
// Convert the indirect result to a direct result.
801
- SILType SILResTy =
802
- SILType::getPrimitiveObjectType (RI.getReturnValueType (M, SubstFTy));
803
-
804
808
// Indirect results are passed as owned, so we also need to pass the
805
809
// direct result as owned (except it's a trivial type).
806
- auto C = (SILResTy. isTrivial (*Callee)
810
+ auto C = (isTrivial
807
811
? ResultConvention::Unowned
808
812
: ResultConvention::Owned);
809
813
SpecializedResults.push_back (SILResultInfo (RI.getReturnValueType (M, SubstFTy), C));
@@ -815,21 +819,19 @@ createSpecializedType(CanSILFunctionType SubstFTy, SILModule &M) const {
815
819
}
816
820
unsigned ParamIdx = 0 ;
817
821
for (SILParameterInfo PI : SubstFTy->getParameters ()) {
822
+ bool isTrivial = TrivialArgs.test (param2ArgIndex (ParamIdx));
818
823
if (!isParamConverted (ParamIdx++)) {
819
824
// No conversion: re-use the original, substituted parameter info.
820
825
SpecializedParams.push_back (PI);
821
826
continue ;
822
827
}
823
828
824
829
// Convert the indirect parameter to a direct parameter.
825
- SILType SILParamTy =
826
- SILType::getPrimitiveObjectType (PI.getArgumentType (M, SubstFTy));
827
-
828
830
// Indirect parameters are passed as owned/guaranteed, so we also
829
831
// need to pass the direct/guaranteed parameter as
830
832
// owned/guaranteed (except it's a trivial type).
831
833
auto C = ParameterConvention::Direct_Unowned;
832
- if (!SILParamTy. isTrivial (*Callee) ) {
834
+ if (!isTrivial) {
833
835
if (PI.isGuaranteed ()) {
834
836
C = ParameterConvention::Direct_Guaranteed;
835
837
} else {
0 commit comments