@@ -639,9 +639,7 @@ namespace {
639
639
}
640
640
641
641
// / 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 ); }
645
643
646
644
void addCoroutineContextParameter ();
647
645
void addCoroutineAllocatorParameter ();
@@ -674,7 +672,7 @@ llvm::Type *SignatureExpansion::addIndirectResult(SILType resultType,
674
672
auto storageTy = resultTI.getStorageType ();
675
673
addIndirectResultAttributes (IGM, Attrs, ParamIRTypes.size (), claimSRet (),
676
674
storageTy, resultTI, useInReg);
677
- addPointerParameter (storageTy );
675
+ addOpaquePointerParameter ( );
678
676
return IGM.VoidTy ;
679
677
}
680
678
@@ -749,7 +747,7 @@ void SignatureExpansion::expandIndirectResults() {
749
747
}
750
748
addIndirectResultAttributes (IGM, Attrs, ParamIRTypes.size (), useSRet,
751
749
storageTy, typeInfo);
752
- addPointerParameter (storageTy );
750
+ addOpaquePointerParameter ( );
753
751
}
754
752
}
755
753
@@ -787,9 +785,9 @@ namespace {
787
785
// / Is the yielded value formally indirect?
788
786
bool isFormalIndirect () const { return YieldTy.isAddress (); }
789
787
790
- llvm::PointerType *getIndirectPointerType () const {
788
+ llvm::PointerType *getIndirectPointerType (IRGenModule &IGM ) const {
791
789
assert (isIndirect ());
792
- return YieldTI. getStorageType ()-> getPointerTo () ;
790
+ return IGM. PtrTy ;
793
791
}
794
792
795
793
const NativeConventionSchema &getDirectSchema () const {
@@ -849,7 +847,7 @@ void SignatureExpansion::expandCoroutineResult(bool forContinuation) {
849
847
850
848
// If the individual value must be yielded indirectly, add a pointer.
851
849
if (schema.isIndirect ()) {
852
- components.push_back (schema.getIndirectPointerType ());
850
+ components.push_back (schema.getIndirectPointerType (IGM ));
853
851
continue ;
854
852
}
855
853
@@ -891,7 +889,7 @@ void SignatureExpansion::expandCoroutineResult(bool forContinuation) {
891
889
// trusting LLVM's?
892
890
CoroInfo.indirectResultsType =
893
891
llvm::StructType::get (IGM.getLLVMContext (), overflowTypes);
894
- components.back () = CoroInfo. indirectResultsType -> getPointerTo () ;
892
+ components.back () = IGM. PtrTy ;
895
893
}
896
894
897
895
ResultIRType = components.size () == 1
@@ -1724,7 +1722,7 @@ void SignatureExpansion::expandExternalSignatureTypes() {
1724
1722
Alignment (AI.getIndirectAlign ().getQuantity ()),
1725
1723
paramTI.getStorageType ());
1726
1724
}
1727
- addPointerParameter (paramTI. getStorageType () );
1725
+ addOpaquePointerParameter ( );
1728
1726
break ;
1729
1727
}
1730
1728
case clang::CodeGen::ABIArgInfo::Expand:
@@ -1799,8 +1797,7 @@ const TypeInfo &SignatureExpansion::expand(unsigned paramIdx) {
1799
1797
case ParameterConvention::Indirect_In_CXX:
1800
1798
addIndirectValueParameterAttributes (IGM, Attrs, ti, ParamIRTypes.size (),
1801
1799
isAddressableParam (paramIdx));
1802
- addPointerParameter (IGM.getStorageType (getSILFuncConventions ().getSILType (
1803
- param, IGM.getMaximalTypeExpansionContext ())));
1800
+ addOpaquePointerParameter ();
1804
1801
return ti;
1805
1802
1806
1803
case ParameterConvention::Indirect_Inout:
@@ -1809,15 +1806,14 @@ const TypeInfo &SignatureExpansion::expand(unsigned paramIdx) {
1809
1806
IGM, paramSILType, Attrs, ti, ParamIRTypes.size (),
1810
1807
conv == ParameterConvention::Indirect_InoutAliasable,
1811
1808
isAddressableParam (paramIdx));
1812
- addPointerParameter (IGM.getStorageType (getSILFuncConventions ().getSILType (
1813
- param, IGM.getMaximalTypeExpansionContext ())));
1809
+ addOpaquePointerParameter ();
1814
1810
return ti;
1815
1811
1816
1812
case ParameterConvention::Pack_Guaranteed:
1817
1813
case ParameterConvention::Pack_Owned:
1818
1814
case ParameterConvention::Pack_Inout:
1819
1815
addPackParameterAttributes (IGM, paramSILType, Attrs, ParamIRTypes.size ());
1820
- addPointerParameter (ti. getStorageType () );
1816
+ addOpaquePointerParameter ( );
1821
1817
return ti;
1822
1818
1823
1819
case ParameterConvention::Direct_Owned:
@@ -1834,7 +1830,7 @@ const TypeInfo &SignatureExpansion::expand(unsigned paramIdx) {
1834
1830
addIndirectValueParameterAttributes (IGM, Attrs, ti,
1835
1831
ParamIRTypes.size (),
1836
1832
/* addressable*/ false );
1837
- ParamIRTypes. push_back (ti. getStorageType ()-> getPointerTo () );
1833
+ addOpaquePointerParameter ( );
1838
1834
return ti;
1839
1835
}
1840
1836
if (nativeSchema.empty ()) {
@@ -1989,8 +1985,8 @@ void SignatureExpansion::expandParameters(
1989
1985
auto fnConv = getSILFuncConventions ();
1990
1986
for (auto indirectResultType : fnConv.getIndirectSILResultTypes (
1991
1987
IGM.getMaximalTypeExpansionContext ())) {
1992
- auto storageTy = IGM. getStorageType (indirectResultType) ;
1993
- addPointerParameter (storageTy );
1988
+ ( void )indirectResultType ;
1989
+ addOpaquePointerParameter ( );
1994
1990
}
1995
1991
break ;
1996
1992
}
@@ -2079,8 +2075,7 @@ void SignatureExpansion::expandParameters(
2079
2075
if (FnType->hasErrorResult ()) {
2080
2076
if (claimError ())
2081
2077
IGM.addSwiftErrorAttributes (Attrs, ParamIRTypes.size ());
2082
- llvm::Type *errorType = getErrorRegisterType ();
2083
- ParamIRTypes.push_back (errorType->getPointerTo ());
2078
+ addOpaquePointerParameter ();
2084
2079
if (recordedABIDetails)
2085
2080
recordedABIDetails->hasErrorResult = true ;
2086
2081
if (getSILFuncConventions ().isTypedError ()) {
@@ -2098,7 +2093,7 @@ void SignatureExpansion::expandParameters(
2098
2093
getSILFuncConventions ().hasIndirectSILErrorResults () ||
2099
2094
native.requiresIndirect () ||
2100
2095
nativeError.shouldReturnTypedErrorIndirectly ()) {
2101
- ParamIRTypes. push_back (IGM. getStorageType (errorType)-> getPointerTo () );
2096
+ addOpaquePointerParameter ( );
2102
2097
}
2103
2098
}
2104
2099
}
@@ -2241,8 +2236,7 @@ void SignatureExpansion::addIndirectThrowingResult() {
2241
2236
getSILFuncConventions ().hasIndirectSILErrorResults () ||
2242
2237
native.requiresIndirect () ||
2243
2238
nativeError.shouldReturnTypedErrorIndirectly ()) {
2244
- auto errorStorageTy = errorTI.getStorageType ();
2245
- ParamIRTypes.push_back (errorStorageTy->getPointerTo ());
2239
+ addOpaquePointerParameter ();
2246
2240
}
2247
2241
}
2248
2242
@@ -2566,8 +2560,7 @@ llvm::Value *emitIndirectAsyncFunctionPointer(IRGenFunction &IGF,
2566
2560
2567
2561
llvm::Value *UntaggedPointer = IGF.Builder .CreateAnd (PtrToInt, NegativeOne);
2568
2562
llvm::Value *IntToPtr =
2569
- IGF.Builder .CreateIntToPtr (UntaggedPointer,
2570
- AsyncFunctionPointerPtrTy->getPointerTo ());
2563
+ IGF.Builder .CreateIntToPtr (UntaggedPointer, IGF.IGM .PtrTy );
2571
2564
llvm::Value *Load = IGF.Builder .CreateLoad (
2572
2565
IntToPtr, AsyncFunctionPointerPtrTy, PointerAlignment);
2573
2566
@@ -2596,8 +2589,8 @@ llvm::Value *emitIndirectCoroFunctionPointer(IRGenFunction &IGF,
2596
2589
IGF.Builder .CreateBitCast (pointer, CoroFunctionPointerPtrTy);
2597
2590
2598
2591
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 );
2601
2594
llvm::Value *Load = IGF.Builder .CreateLoad (IntToPtr, CoroFunctionPointerPtrTy,
2602
2595
PointerAlignment);
2603
2596
@@ -3236,9 +3229,8 @@ class AsyncCallEmission final : public CallEmission {
3236
3229
getCallee ().getFunctionPointer ().getKind ());
3237
3230
3238
3231
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 ());
3242
3234
}
3243
3235
3244
3236
SILType getParameterType (unsigned index) override {
@@ -3913,8 +3905,9 @@ void CallEmission::emitYieldsToExplosion(Explosion &out) {
3913
3905
3914
3906
// If the schema says it's indirect, then we expect a pointer.
3915
3907
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 ));
3918
3911
3919
3912
// If it's formally indirect, then we should just add that pointer
3920
3913
// to the output.
@@ -5190,8 +5183,7 @@ static llvm::Constant *getCoroAllocFn(IRGenModule &IGM) {
5190
5183
{llvm::ConstantInt::get (IGF.IGM .Int32Ty , 0 ),
5191
5184
llvm::ConstantInt::get (IGF.IGM .Int32Ty , 1 )});
5192
5185
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 ()),
5195
5187
" allocate_fn" );
5196
5188
auto fnPtr = FunctionPointer::createUnsigned (
5197
5189
FunctionPointer::Kind::Function, callee,
@@ -5268,8 +5260,7 @@ static llvm::Constant *getCoroDeallocFn(IRGenModule &IGM) {
5268
5260
{llvm::ConstantInt::get (IGF.IGM .Int32Ty , 0 ),
5269
5261
llvm::ConstantInt::get (IGF.IGM .Int32Ty , 2 )});
5270
5262
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 ()),
5273
5264
" deallocate_fn" );
5274
5265
auto fnPtr = FunctionPointer::createUnsigned (
5275
5266
FunctionPointer::Kind::Function, callee,
@@ -6412,8 +6403,7 @@ Explosion IRGenFunction::coerceValueTo(SILType fromTy, Explosion &from,
6412
6403
auto temporary = toTI.allocateStack (*this , toTy, " coerce.temp" );
6413
6404
6414
6405
auto addr =
6415
- Address (Builder.CreateBitCast (temporary.getAddressPointer (),
6416
- fromTI.getStorageType ()->getPointerTo ()),
6406
+ Address (Builder.CreateBitCast (temporary.getAddressPointer (), IGM.PtrTy ),
6417
6407
fromTI.getStorageType (), temporary.getAlignment ());
6418
6408
fromTI.initialize (*this , from, addr, false );
6419
6409
@@ -6549,7 +6539,7 @@ Signature irgen::emitCastOfFunctionPointer(IRGenFunction &IGF,
6549
6539
: IGF.IGM .getSignature (fnType);
6550
6540
6551
6541
// Emit the cast.
6552
- fnPtr = IGF.Builder .CreateBitCast (fnPtr, sig. getType ()-> getPointerTo () );
6542
+ fnPtr = IGF.Builder .CreateBitCast (fnPtr, IGF. IGM . PtrTy );
6553
6543
6554
6544
// Return the information.
6555
6545
return sig;
@@ -7038,7 +7028,7 @@ IRGenFunction::getFunctionPointerForResumeIntrinsic(llvm::Value *resume) {
7038
7028
Signature (fnTy, attrs, IGM.SwiftAsyncCC );
7039
7029
auto fnPtr = FunctionPointer::createUnsigned (
7040
7030
FunctionPointer::Kind::Function,
7041
- Builder.CreateBitOrPointerCast (resume, fnTy-> getPointerTo () ), signature);
7031
+ Builder.CreateBitOrPointerCast (resume, IGM. PtrTy ), signature);
7042
7032
return fnPtr;
7043
7033
}
7044
7034
0 commit comments