@@ -817,8 +817,8 @@ ArgumentDecoderInfo DistributedAccessor::findArgumentDecoder(
817
817
// is passed indirectly. This is good for structs and enums because
818
818
// `decodeNextArgument` is a mutating method, but not for classes because
819
819
// in that case heap object is mutated directly.
820
- llvm::Function *fnPtr = nullptr ;
821
820
bool usesDispatchThunk = false ;
821
+
822
822
if (auto classDecl = dyn_cast<ClassDecl>(decoderDecl)) {
823
823
auto selfTy = methodTy->getSelfParameter ().getSILStorageType (
824
824
IGM.getSILModule (), methodTy, expansionContext);
@@ -841,29 +841,23 @@ ArgumentDecoderInfo DistributedAccessor::findArgumentDecoder(
841
841
842
842
// / When using library evolution functions have another "dispatch thunk"
843
843
// / so we must use this instead of the decodeFn directly.
844
- if (classDecl->hasResilientMetadata ()) {
845
- if (getMethodDispatch (decodeFn) == swift::MethodDispatch::Class) {
846
- fnPtr = IGM.getAddrOfDispatchThunk (SILDeclRef (decodeFn), NotForDefinition);
847
- usesDispatchThunk = true ;
848
- }
849
- }
844
+ usesDispatchThunk =
845
+ getMethodDispatch (decodeFn) == swift::MethodDispatch::Class &&
846
+ classDecl->hasResilientMetadata ();
850
847
}
851
848
852
- if (!fnPtr) {
853
- auto *decodeSIL = IGM.getSILModule ().lookUpFunction (SILDeclRef (decodeFn));
854
- fnPtr = IGM.getAddrOfSILFunction (decodeSIL, NotForDefinition,
855
- /* isDynamicallyReplaceable=*/ false );
856
- }
857
- assert (fnPtr);
858
-
859
849
FunctionPointer methodPtr;
850
+
860
851
if (usesDispatchThunk) {
852
+ auto fnPtr = IGM.getAddrOfDispatchThunk (SILDeclRef (decodeFn), NotForDefinition);
861
853
methodPtr = FunctionPointer::createUnsigned (
862
854
methodTy, fnPtr, signature, /* useSignature=*/ true );
863
855
} else {
864
- auto *decodeSIL = IGM.getSILModule ().lookUpFunction (SILDeclRef (decodeFn));
856
+ SILFunction *decodeSILFn = IGM.getSILModule ().lookUpFunction (SILDeclRef (decodeFn));
857
+ auto fnPtr = IGM.getAddrOfSILFunction (decodeSILFn, NotForDefinition,
858
+ /* isDynamicallyReplaceable=*/ false );
865
859
methodPtr = FunctionPointer::forDirect (
866
- classifyFunctionPointerKind (decodeSIL ), fnPtr,
860
+ classifyFunctionPointerKind (decodeSILFn ), fnPtr,
867
861
/* secondaryValue=*/ nullptr , signature);
868
862
}
869
863
0 commit comments