@@ -817,8 +817,8 @@ ArgumentDecoderInfo DistributedAccessor::findArgumentDecoder(
817817 // is passed indirectly. This is good for structs and enums because
818818 // `decodeNextArgument` is a mutating method, but not for classes because
819819 // in that case heap object is mutated directly.
820- llvm::Function *fnPtr = nullptr ;
821820 bool usesDispatchThunk = false ;
821+
822822 if (auto classDecl = dyn_cast<ClassDecl>(decoderDecl)) {
823823 auto selfTy = methodTy->getSelfParameter ().getSILStorageType (
824824 IGM.getSILModule (), methodTy, expansionContext);
@@ -841,29 +841,23 @@ ArgumentDecoderInfo DistributedAccessor::findArgumentDecoder(
841841
842842 // / When using library evolution functions have another "dispatch thunk"
843843 // / 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 ();
850847 }
851848
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-
859849 FunctionPointer methodPtr;
850+
860851 if (usesDispatchThunk) {
852+ auto fnPtr = IGM.getAddrOfDispatchThunk (SILDeclRef (decodeFn), NotForDefinition);
861853 methodPtr = FunctionPointer::createUnsigned (
862854 methodTy, fnPtr, signature, /* useSignature=*/ true );
863855 } 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 );
865859 methodPtr = FunctionPointer::forDirect (
866- classifyFunctionPointerKind (decodeSIL ), fnPtr,
860+ classifyFunctionPointerKind (decodeSILFn ), fnPtr,
867861 /* secondaryValue=*/ nullptr , signature);
868862 }
869863
0 commit comments