@@ -639,9 +639,7 @@ namespace {
639639 }
640640
641641 // / Add a pointer to the given type as the next parameter.
642- void addPointerParameter (llvm::Type *storageType) {
643- ParamIRTypes.push_back (storageType->getPointerTo ());
644- }
642+ void addOpaquePointerParameter () { ParamIRTypes.push_back (IGM.PtrTy ); }
645643
646644 void addCoroutineContextParameter ();
647645 void addCoroutineAllocatorParameter ();
@@ -674,7 +672,7 @@ llvm::Type *SignatureExpansion::addIndirectResult(SILType resultType,
674672 auto storageTy = resultTI.getStorageType ();
675673 addIndirectResultAttributes (IGM, Attrs, ParamIRTypes.size (), claimSRet (),
676674 storageTy, resultTI, useInReg);
677- addPointerParameter (storageTy );
675+ addOpaquePointerParameter ( );
678676 return IGM.VoidTy ;
679677}
680678
@@ -749,7 +747,7 @@ void SignatureExpansion::expandIndirectResults() {
749747 }
750748 addIndirectResultAttributes (IGM, Attrs, ParamIRTypes.size (), useSRet,
751749 storageTy, typeInfo);
752- addPointerParameter (storageTy );
750+ addOpaquePointerParameter ( );
753751 }
754752}
755753
@@ -787,9 +785,9 @@ namespace {
787785 // / Is the yielded value formally indirect?
788786 bool isFormalIndirect () const { return YieldTy.isAddress (); }
789787
790- llvm::PointerType *getIndirectPointerType () const {
788+ llvm::PointerType *getIndirectPointerType (IRGenModule &IGM ) const {
791789 assert (isIndirect ());
792- return YieldTI. getStorageType ()-> getPointerTo () ;
790+ return IGM. PtrTy ;
793791 }
794792
795793 const NativeConventionSchema &getDirectSchema () const {
@@ -849,7 +847,7 @@ void SignatureExpansion::expandCoroutineResult(bool forContinuation) {
849847
850848 // If the individual value must be yielded indirectly, add a pointer.
851849 if (schema.isIndirect ()) {
852- components.push_back (schema.getIndirectPointerType ());
850+ components.push_back (schema.getIndirectPointerType (IGM ));
853851 continue ;
854852 }
855853
@@ -891,7 +889,7 @@ void SignatureExpansion::expandCoroutineResult(bool forContinuation) {
891889 // trusting LLVM's?
892890 CoroInfo.indirectResultsType =
893891 llvm::StructType::get (IGM.getLLVMContext (), overflowTypes);
894- components.back () = CoroInfo. indirectResultsType -> getPointerTo () ;
892+ components.back () = IGM. PtrTy ;
895893 }
896894
897895 ResultIRType = components.size () == 1
@@ -1724,7 +1722,7 @@ void SignatureExpansion::expandExternalSignatureTypes() {
17241722 Alignment (AI.getIndirectAlign ().getQuantity ()),
17251723 paramTI.getStorageType ());
17261724 }
1727- addPointerParameter (paramTI. getStorageType () );
1725+ addOpaquePointerParameter ( );
17281726 break ;
17291727 }
17301728 case clang::CodeGen::ABIArgInfo::Expand:
@@ -1799,8 +1797,7 @@ const TypeInfo &SignatureExpansion::expand(unsigned paramIdx) {
17991797 case ParameterConvention::Indirect_In_CXX:
18001798 addIndirectValueParameterAttributes (IGM, Attrs, ti, ParamIRTypes.size (),
18011799 isAddressableParam (paramIdx));
1802- addPointerParameter (IGM.getStorageType (getSILFuncConventions ().getSILType (
1803- param, IGM.getMaximalTypeExpansionContext ())));
1800+ addOpaquePointerParameter ();
18041801 return ti;
18051802
18061803 case ParameterConvention::Indirect_Inout:
@@ -1809,15 +1806,14 @@ const TypeInfo &SignatureExpansion::expand(unsigned paramIdx) {
18091806 IGM, paramSILType, Attrs, ti, ParamIRTypes.size (),
18101807 conv == ParameterConvention::Indirect_InoutAliasable,
18111808 isAddressableParam (paramIdx));
1812- addPointerParameter (IGM.getStorageType (getSILFuncConventions ().getSILType (
1813- param, IGM.getMaximalTypeExpansionContext ())));
1809+ addOpaquePointerParameter ();
18141810 return ti;
18151811
18161812 case ParameterConvention::Pack_Guaranteed:
18171813 case ParameterConvention::Pack_Owned:
18181814 case ParameterConvention::Pack_Inout:
18191815 addPackParameterAttributes (IGM, paramSILType, Attrs, ParamIRTypes.size ());
1820- addPointerParameter (ti. getStorageType () );
1816+ addOpaquePointerParameter ( );
18211817 return ti;
18221818
18231819 case ParameterConvention::Direct_Owned:
@@ -1834,7 +1830,7 @@ const TypeInfo &SignatureExpansion::expand(unsigned paramIdx) {
18341830 addIndirectValueParameterAttributes (IGM, Attrs, ti,
18351831 ParamIRTypes.size (),
18361832 /* addressable*/ false );
1837- ParamIRTypes. push_back (ti. getStorageType ()-> getPointerTo () );
1833+ addOpaquePointerParameter ( );
18381834 return ti;
18391835 }
18401836 if (nativeSchema.empty ()) {
@@ -1989,8 +1985,8 @@ void SignatureExpansion::expandParameters(
19891985 auto fnConv = getSILFuncConventions ();
19901986 for (auto indirectResultType : fnConv.getIndirectSILResultTypes (
19911987 IGM.getMaximalTypeExpansionContext ())) {
1992- auto storageTy = IGM. getStorageType (indirectResultType) ;
1993- addPointerParameter (storageTy );
1988+ ( void )indirectResultType ;
1989+ addOpaquePointerParameter ( );
19941990 }
19951991 break ;
19961992 }
@@ -2079,8 +2075,7 @@ void SignatureExpansion::expandParameters(
20792075 if (FnType->hasErrorResult ()) {
20802076 if (claimError ())
20812077 IGM.addSwiftErrorAttributes (Attrs, ParamIRTypes.size ());
2082- llvm::Type *errorType = getErrorRegisterType ();
2083- ParamIRTypes.push_back (errorType->getPointerTo ());
2078+ addOpaquePointerParameter ();
20842079 if (recordedABIDetails)
20852080 recordedABIDetails->hasErrorResult = true ;
20862081 if (getSILFuncConventions ().isTypedError ()) {
@@ -2098,7 +2093,7 @@ void SignatureExpansion::expandParameters(
20982093 getSILFuncConventions ().hasIndirectSILErrorResults () ||
20992094 native.requiresIndirect () ||
21002095 nativeError.shouldReturnTypedErrorIndirectly ()) {
2101- ParamIRTypes. push_back (IGM. getStorageType (errorType)-> getPointerTo () );
2096+ addOpaquePointerParameter ( );
21022097 }
21032098 }
21042099 }
@@ -2241,8 +2236,7 @@ void SignatureExpansion::addIndirectThrowingResult() {
22412236 getSILFuncConventions ().hasIndirectSILErrorResults () ||
22422237 native.requiresIndirect () ||
22432238 nativeError.shouldReturnTypedErrorIndirectly ()) {
2244- auto errorStorageTy = errorTI.getStorageType ();
2245- ParamIRTypes.push_back (errorStorageTy->getPointerTo ());
2239+ addOpaquePointerParameter ();
22462240 }
22472241 }
22482242
@@ -2566,8 +2560,7 @@ llvm::Value *emitIndirectAsyncFunctionPointer(IRGenFunction &IGF,
25662560
25672561 llvm::Value *UntaggedPointer = IGF.Builder .CreateAnd (PtrToInt, NegativeOne);
25682562 llvm::Value *IntToPtr =
2569- IGF.Builder .CreateIntToPtr (UntaggedPointer,
2570- AsyncFunctionPointerPtrTy->getPointerTo ());
2563+ IGF.Builder .CreateIntToPtr (UntaggedPointer, IGF.IGM .PtrTy );
25712564 llvm::Value *Load = IGF.Builder .CreateLoad (
25722565 IntToPtr, AsyncFunctionPointerPtrTy, PointerAlignment);
25732566
@@ -2596,8 +2589,8 @@ llvm::Value *emitIndirectCoroFunctionPointer(IRGenFunction &IGF,
25962589 IGF.Builder .CreateBitCast (pointer, CoroFunctionPointerPtrTy);
25972590
25982591 llvm::Value *UntaggedPointer = IGF.Builder .CreateAnd (PtrToInt, NegativeOne);
2599- llvm::Value *IntToPtr = IGF. Builder . CreateIntToPtr (
2600- UntaggedPointer, CoroFunctionPointerPtrTy-> getPointerTo () );
2592+ llvm::Value *IntToPtr =
2593+ IGF. Builder . CreateIntToPtr ( UntaggedPointer, IGF. IGM . PtrTy );
26012594 llvm::Value *Load = IGF.Builder .CreateLoad (IntToPtr, CoroFunctionPointerPtrTy,
26022595 PointerAlignment);
26032596
@@ -3236,9 +3229,8 @@ class AsyncCallEmission final : public CallEmission {
32363229 getCallee ().getFunctionPointer ().getKind ());
32373230
32383231 return FunctionPointer::createForAsyncCall (
3239- IGF.Builder .CreateBitCast (calleeFunction,
3240- awaitEntrySig.getType ()->getPointerTo ()),
3241- codeAuthInfo, awaitSig, awaitEntrySig.getType ());
3232+ IGF.Builder .CreateBitCast (calleeFunction, IGF.IGM .PtrTy ), codeAuthInfo,
3233+ awaitSig, awaitEntrySig.getType ());
32423234 }
32433235
32443236 SILType getParameterType (unsigned index) override {
@@ -3913,8 +3905,9 @@ void CallEmission::emitYieldsToExplosion(Explosion &out) {
39133905
39143906 // If the schema says it's indirect, then we expect a pointer.
39153907 if (schema.isIndirect ()) {
3916- auto pointer = IGF.Builder .CreateBitCast (rawYieldComponents.claimNext (),
3917- schema.getIndirectPointerType ());
3908+ auto pointer =
3909+ IGF.Builder .CreateBitCast (rawYieldComponents.claimNext (),
3910+ schema.getIndirectPointerType (IGF.IGM ));
39183911
39193912 // If it's formally indirect, then we should just add that pointer
39203913 // to the output.
@@ -5190,8 +5183,7 @@ static llvm::Constant *getCoroAllocFn(IRGenModule &IGM) {
51905183 {llvm::ConstantInt::get (IGF.IGM .Int32Ty , 0 ),
51915184 llvm::ConstantInt::get (IGF.IGM .Int32Ty , 1 )});
51925185 auto *callee = IGF.Builder .CreateLoad (
5193- Address (calleePtr, IGF.IGM .CoroAllocateFnTy ->getPointerTo (),
5194- IGF.IGM .getPointerAlignment ()),
5186+ Address (calleePtr, IGF.IGM .PtrTy , IGF.IGM .getPointerAlignment ()),
51955187 " allocate_fn" );
51965188 auto fnPtr = FunctionPointer::createUnsigned (
51975189 FunctionPointer::Kind::Function, callee,
@@ -5268,8 +5260,7 @@ static llvm::Constant *getCoroDeallocFn(IRGenModule &IGM) {
52685260 {llvm::ConstantInt::get (IGF.IGM .Int32Ty , 0 ),
52695261 llvm::ConstantInt::get (IGF.IGM .Int32Ty , 2 )});
52705262 auto *callee = IGF.Builder .CreateLoad (
5271- Address (calleePtr, IGF.IGM .CoroDeallocateFnTy ->getPointerTo (),
5272- IGF.IGM .getPointerAlignment ()),
5263+ Address (calleePtr, IGF.IGM .PtrTy , IGF.IGM .getPointerAlignment ()),
52735264 " deallocate_fn" );
52745265 auto fnPtr = FunctionPointer::createUnsigned (
52755266 FunctionPointer::Kind::Function, callee,
@@ -6412,8 +6403,7 @@ Explosion IRGenFunction::coerceValueTo(SILType fromTy, Explosion &from,
64126403 auto temporary = toTI.allocateStack (*this , toTy, " coerce.temp" );
64136404
64146405 auto addr =
6415- Address (Builder.CreateBitCast (temporary.getAddressPointer (),
6416- fromTI.getStorageType ()->getPointerTo ()),
6406+ Address (Builder.CreateBitCast (temporary.getAddressPointer (), IGM.PtrTy ),
64176407 fromTI.getStorageType (), temporary.getAlignment ());
64186408 fromTI.initialize (*this , from, addr, false );
64196409
@@ -6549,7 +6539,7 @@ Signature irgen::emitCastOfFunctionPointer(IRGenFunction &IGF,
65496539 : IGF.IGM .getSignature (fnType);
65506540
65516541 // Emit the cast.
6552- fnPtr = IGF.Builder .CreateBitCast (fnPtr, sig. getType ()-> getPointerTo () );
6542+ fnPtr = IGF.Builder .CreateBitCast (fnPtr, IGF. IGM . PtrTy );
65536543
65546544 // Return the information.
65556545 return sig;
@@ -7038,7 +7028,7 @@ IRGenFunction::getFunctionPointerForResumeIntrinsic(llvm::Value *resume) {
70387028 Signature (fnTy, attrs, IGM.SwiftAsyncCC );
70397029 auto fnPtr = FunctionPointer::createUnsigned (
70407030 FunctionPointer::Kind::Function,
7041- Builder.CreateBitOrPointerCast (resume, fnTy-> getPointerTo () ), signature);
7031+ Builder.CreateBitOrPointerCast (resume, IGM. PtrTy ), signature);
70427032 return fnPtr;
70437033}
70447034
0 commit comments