@@ -914,23 +914,14 @@ void SILGenFunction::emitAsyncMainThreadStart(SILDeclRef entryPoint) {
914
914
915
915
B.setInsertionPoint (entryBlock);
916
916
917
- // / Generates a reinterpret_cast for converting
918
- // / Builtin.Job -> UnownedJob
919
- // / Builtin.Executor -> UnownedSerialExecutor
920
- // / These are used by _swiftJobRun, which, ABI-wise, could take
921
- // / Builtin.Job or Builtin.Executor, but doesn't.
922
- auto createExplodyCastForCall =
923
- [this , &moduleLoc](SILValue originalValue, FuncDecl *jobRunFuncDecl,
924
- uint32_t paramIndex) -> SILValue {
925
- // The type coming from the _swiftJobRun function
926
- Type apiType = jobRunFuncDecl->getParameters ()->get (paramIndex)->getType ();
927
- SILType apiSILType =
928
- SILType::getPrimitiveObjectType (apiType->getCanonicalType ());
917
+ auto wrapCallArgs = [this , &moduleLoc](SILValue originalValue, FuncDecl *fd,
918
+ uint32_t paramIndex) -> SILValue {
919
+ Type parameterType = fd->getParameters ()->get (paramIndex)->getType ();
920
+ SILType paramSILType = SILType::getPrimitiveObjectType (parameterType->getCanonicalType ());
929
921
// If the types are the same, we don't need to do anything!
930
- if (apiSILType == originalValue->getType ())
922
+ if (paramSILType == originalValue->getType ())
931
923
return originalValue;
932
- return this ->B .createUncheckedReinterpretCast (moduleLoc, originalValue,
933
- apiSILType);
924
+ return this ->B .createStruct (moduleLoc, paramSILType, originalValue);
934
925
};
935
926
936
927
// Call CreateAsyncTask
@@ -975,7 +966,7 @@ void SILGenFunction::emitAsyncMainThreadStart(SILDeclRef entryPoint) {
975
966
moduleLoc,
976
967
ctx.getIdentifier (getBuiltinName (BuiltinValueKind::ConvertTaskToJob)),
977
968
JobType, {}, {task});
978
- jobResult = createExplodyCastForCall (jobResult, swiftJobRunFuncDecl, 0 );
969
+ jobResult = wrapCallArgs (jobResult, swiftJobRunFuncDecl, 0 );
979
970
980
971
// Get main executor
981
972
FuncDecl *getMainExecutorFuncDecl = SGM.getGetMainExecutor ();
@@ -985,7 +976,7 @@ void SILGenFunction::emitAsyncMainThreadStart(SILDeclRef entryPoint) {
985
976
SILValue getMainExeutorFunc =
986
977
B.createFunctionRefFor (moduleLoc, getMainExeutorSILFunc);
987
978
SILValue mainExecutor = B.createApply (moduleLoc, getMainExeutorFunc, {}, {});
988
- mainExecutor = createExplodyCastForCall (mainExecutor, swiftJobRunFuncDecl, 1 );
979
+ mainExecutor = wrapCallArgs (mainExecutor, swiftJobRunFuncDecl, 1 );
989
980
990
981
// Run first part synchronously
991
982
B.createApply (moduleLoc, swiftJobRunFunc, {}, {jobResult, mainExecutor});
0 commit comments