@@ -2743,9 +2743,11 @@ emitKeyPathRValueBase(SILGenFunction &subSGF,
2743
2743
// There no real argument to pass to the underlying accessors.
2744
2744
if (!storage->getDeclContext ()->isTypeContext ())
2745
2745
return ManagedValue ();
2746
-
2747
- auto paramOrigValue =
2748
- ManagedValue::forBorrowedRValue (paramArg).copy (subSGF, loc);
2746
+
2747
+ auto paramOrigValue = paramArg->getType ().isTrivial (subSGF.F )
2748
+ ? ManagedValue::forTrivialRValue (paramArg)
2749
+ : ManagedValue::forBorrowedRValue (paramArg);
2750
+ paramOrigValue = paramOrigValue.copy (subSGF, loc);
2749
2751
auto paramSubstValue = subSGF.emitOrigToSubstValue (loc, paramOrigValue,
2750
2752
AbstractionPattern::getOpaque (),
2751
2753
baseType);
@@ -2942,15 +2944,20 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
2942
2944
subSGF.F .getTypeExpansionContext ());
2943
2945
2944
2946
auto entry = thunk->begin ();
2945
- auto resultArgTy = signature->getSingleResult ().getSILStorageType (
2946
- SGM.M , signature, subSGF.F .getTypeExpansionContext ());
2947
- auto baseArgTy = signature->getParameters ()[0 ].getSILStorageType (
2948
- SGM.M , signature, subSGF.F .getTypeExpansionContext ());
2947
+ auto resultArgTy =
2948
+ subSGF.silConv .getSILType (signature->getSingleResult (), signature,
2949
+ subSGF.F .getTypeExpansionContext ());
2950
+ auto baseArgTy =
2951
+ subSGF.silConv .getSILType (signature->getParameters ()[0 ], signature,
2952
+ subSGF.F .getTypeExpansionContext ());
2949
2953
if (genericEnv) {
2950
2954
resultArgTy = genericEnv->mapTypeIntoContext (SGM.M , resultArgTy);
2951
2955
baseArgTy = genericEnv->mapTypeIntoContext (SGM.M , baseArgTy);
2952
2956
}
2953
- auto resultArg = entry->createFunctionArgument (resultArgTy);
2957
+ SILFunctionArgument *resultArg = nullptr ;
2958
+ if (SGM.M .useLoweredAddresses ()) {
2959
+ resultArg = entry->createFunctionArgument (resultArgTy);
2960
+ }
2954
2961
auto baseArg = entry->createFunctionArgument (baseArgTy);
2955
2962
SILValue indexPtrArg;
2956
2963
if (!indexes.empty ()) {
@@ -2997,15 +3004,21 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
2997
3004
resultSubst = std::move (resultRValue).getAsSingleValue (subSGF, loc);
2998
3005
}
2999
3006
3000
- if (resultSubst.getType ().getAddressType () != resultArg-> getType () )
3007
+ if (resultSubst.getType ().getAddressType () != resultArgTy )
3001
3008
resultSubst = subSGF.emitSubstToOrigValue (loc, resultSubst,
3002
3009
AbstractionPattern::getOpaque (),
3003
3010
propertyType);
3004
-
3005
- resultSubst.forwardInto (subSGF, loc, resultArg);
3006
- scope.pop ();
3007
-
3008
- subSGF.B .createReturn (loc, subSGF.emitEmptyTuple (loc));
3011
+
3012
+ if (SGM.M .useLoweredAddresses ()) {
3013
+ resultSubst.forwardInto (subSGF, loc, resultArg);
3014
+ scope.pop ();
3015
+
3016
+ subSGF.B .createReturn (loc, subSGF.emitEmptyTuple (loc));
3017
+ } else {
3018
+ auto result = resultSubst.forward (subSGF);
3019
+ scope.pop ();
3020
+ subSGF.B .createReturn (loc, result);
3021
+ }
3009
3022
3010
3023
SGM.emitLazyConformancesForFunction (thunk);
3011
3024
return thunk;
0 commit comments