@@ -4670,52 +4670,6 @@ ManagedValue SILGenFunction::emitLValueToPointer(SILLocation loc, LValue &&lv,
4670
4670
.getAsSingleValue (*this , loc);
4671
4671
}
4672
4672
4673
- static std::pair<ManagedValue, ManagedValue>
4674
- emitArrayToPointer (SILGenFunction &SGF, SILLocation loc, ManagedValue array,
4675
- SILGenFunction::ArrayAccessInfo accessInfo) {
4676
- auto &ctx = SGF.getASTContext ();
4677
-
4678
- FuncDecl *converter;
4679
- if (accessInfo.AccessKind == AccessKind::Read) {
4680
- converter = ctx.getConvertConstArrayToPointerArgument (nullptr );
4681
- if (array.isLValue ())
4682
- array = SGF.B .createLoadCopy (loc, array);
4683
-
4684
- } else {
4685
- converter = ctx.getConvertMutableArrayToPointerArgument (nullptr );
4686
- assert (array.isLValue ());
4687
- }
4688
-
4689
- // Invoke the conversion intrinsic, which will produce an owner-pointer pair.
4690
- auto *M = SGF.SGM .M .getSwiftModule ();
4691
- auto firstSubMap =
4692
- accessInfo.ArrayType ->getContextSubstitutionMap (M, ctx.getArrayDecl ());
4693
- auto secondSubMap =
4694
- accessInfo.PointerType ->getContextSubstitutionMap (M,
4695
- SGF.getPointerProtocol ());
4696
-
4697
- auto *genericSig = converter->getGenericSignature ();
4698
- auto subMap =
4699
- SubstitutionMap::combineSubstitutionMaps (firstSubMap,
4700
- secondSubMap,
4701
- CombineSubstitutionMaps::AtIndex,
4702
- 1 , 0 ,
4703
- genericSig);
4704
-
4705
- SmallVector<ManagedValue, 2 > resultScalars;
4706
- SGF.emitApplyOfLibraryIntrinsic (loc, converter, subMap, array, SGFContext ())
4707
- .getAll (resultScalars);
4708
- assert (resultScalars.size () == 2 );
4709
-
4710
- // Mark the dependence of the pointer on the owner value.
4711
- auto owner = resultScalars[0 ];
4712
- auto pointer = resultScalars[1 ].forward (SGF);
4713
- pointer = SGF.B .createMarkDependence (loc, pointer, owner.getValue ());
4714
-
4715
- // The owner's already in its own cleanup. Return the pointer.
4716
- return {ManagedValue::forTrivialObjectRValue (pointer), owner};
4717
- }
4718
-
4719
4673
RValue RValueEmitter::visitArrayToPointerExpr (ArrayToPointerExpr *E,
4720
4674
SGFContext C) {
4721
4675
FormalEvaluationScope writeback (SGF);
@@ -4734,7 +4688,7 @@ RValue RValueEmitter::visitArrayToPointerExpr(ArrayToPointerExpr *E,
4734
4688
array = SGF.emitRValueAsSingleValue (subExpr);
4735
4689
}
4736
4690
4737
- auto pointer = :: emitArrayToPointer (SGF, E, array, accessInfo).first ;
4691
+ auto pointer = SGF. emitArrayToPointer (E, array, accessInfo).first ;
4738
4692
return RValue (SGF, E, pointer);
4739
4693
}
4740
4694
@@ -4749,13 +4703,49 @@ SILGenFunction::emitArrayToPointer(SILLocation loc, LValue &&lv,
4749
4703
ArrayAccessInfo accessInfo) {
4750
4704
auto array =
4751
4705
emitAddressOfLValue (loc, std::move (lv), accessInfo.AccessKind );
4752
- return :: emitArrayToPointer (* this , loc, array, accessInfo);
4706
+ return emitArrayToPointer (loc, array, accessInfo);
4753
4707
}
4754
4708
4755
4709
std::pair<ManagedValue, ManagedValue>
4756
4710
SILGenFunction::emitArrayToPointer (SILLocation loc, ManagedValue array,
4757
4711
ArrayAccessInfo accessInfo) {
4758
- return ::emitArrayToPointer (*this , loc, array, accessInfo);
4712
+ auto &ctx = getASTContext ();
4713
+
4714
+ FuncDecl *converter;
4715
+ if (accessInfo.AccessKind == AccessKind::Read) {
4716
+ converter = ctx.getConvertConstArrayToPointerArgument (nullptr );
4717
+ if (array.isLValue ())
4718
+ array = B.createLoadCopy (loc, array);
4719
+
4720
+ } else {
4721
+ converter = ctx.getConvertMutableArrayToPointerArgument (nullptr );
4722
+ assert (array.isLValue ());
4723
+ }
4724
+
4725
+ // Invoke the conversion intrinsic, which will produce an owner-pointer pair.
4726
+ auto *M = SGM.M .getSwiftModule ();
4727
+ auto firstSubMap =
4728
+ accessInfo.ArrayType ->getContextSubstitutionMap (M, ctx.getArrayDecl ());
4729
+ auto secondSubMap = accessInfo.PointerType ->getContextSubstitutionMap (
4730
+ M, getPointerProtocol ());
4731
+
4732
+ auto *genericSig = converter->getGenericSignature ();
4733
+ auto subMap = SubstitutionMap::combineSubstitutionMaps (
4734
+ firstSubMap, secondSubMap, CombineSubstitutionMaps::AtIndex, 1 , 0 ,
4735
+ genericSig);
4736
+
4737
+ SmallVector<ManagedValue, 2 > resultScalars;
4738
+ emitApplyOfLibraryIntrinsic (loc, converter, subMap, array, SGFContext ())
4739
+ .getAll (resultScalars);
4740
+ assert (resultScalars.size () == 2 );
4741
+
4742
+ // Mark the dependence of the pointer on the owner value.
4743
+ auto owner = resultScalars[0 ];
4744
+ auto pointer = resultScalars[1 ].forward (*this );
4745
+ pointer = B.createMarkDependence (loc, pointer, owner.getValue ());
4746
+
4747
+ // The owner's already in its own cleanup. Return the pointer.
4748
+ return {ManagedValue::forTrivialObjectRValue (pointer), owner};
4759
4749
}
4760
4750
4761
4751
RValue RValueEmitter::visitStringToPointerExpr (StringToPointerExpr *E,
0 commit comments