@@ -868,23 +868,14 @@ void SILGenFunction::emitAsyncMainThreadStart(SILDeclRef entryPoint) {
868
868
869
869
B.setInsertionPoint (entryBlock);
870
870
871
- // / Generates a reinterpret_cast for converting
872
- // / Builtin.Job -> UnownedJob
873
- // / Builtin.Executor -> UnownedSerialExecutor
874
- // / These are used by _swiftJobRun, which, ABI-wise, could take
875
- // / Builtin.Job or Builtin.Executor, but doesn't.
876
- auto createExplodyCastForCall =
877
- [this , &moduleLoc](SILValue originalValue, FuncDecl *jobRunFuncDecl,
878
- uint32_t paramIndex) -> SILValue {
879
- // The type coming from the _swiftJobRun function
880
- Type apiType = jobRunFuncDecl->getParameters ()->get (paramIndex)->getType ();
881
- SILType apiSILType =
882
- SILType::getPrimitiveObjectType (apiType->getCanonicalType ());
871
+ auto wrapCallArgs = [this , &moduleLoc](SILValue originalValue, FuncDecl *fd,
872
+ uint32_t paramIndex) -> SILValue {
873
+ Type parameterType = fd->getParameters ()->get (paramIndex)->getType ();
874
+ SILType paramSILType = SILType::getPrimitiveObjectType (parameterType->getCanonicalType ());
883
875
// If the types are the same, we don't need to do anything!
884
- if (apiSILType == originalValue->getType ())
876
+ if (paramSILType == originalValue->getType ())
885
877
return originalValue;
886
- return this ->B .createUncheckedReinterpretCast (moduleLoc, originalValue,
887
- apiSILType);
878
+ return this ->B .createStruct (moduleLoc, paramSILType, originalValue);
888
879
};
889
880
890
881
// Call CreateAsyncTask
@@ -929,7 +920,7 @@ void SILGenFunction::emitAsyncMainThreadStart(SILDeclRef entryPoint) {
929
920
moduleLoc,
930
921
ctx.getIdentifier (getBuiltinName (BuiltinValueKind::ConvertTaskToJob)),
931
922
JobType, {}, {task});
932
- jobResult = createExplodyCastForCall (jobResult, swiftJobRunFuncDecl, 0 );
923
+ jobResult = wrapCallArgs (jobResult, swiftJobRunFuncDecl, 0 );
933
924
934
925
// Get main executor
935
926
FuncDecl *getMainExecutorFuncDecl = SGM.getGetMainExecutor ();
@@ -939,7 +930,7 @@ void SILGenFunction::emitAsyncMainThreadStart(SILDeclRef entryPoint) {
939
930
SILValue getMainExeutorFunc =
940
931
B.createFunctionRefFor (moduleLoc, getMainExeutorSILFunc);
941
932
SILValue mainExecutor = B.createApply (moduleLoc, getMainExeutorFunc, {}, {});
942
- mainExecutor = createExplodyCastForCall (mainExecutor, swiftJobRunFuncDecl, 1 );
933
+ mainExecutor = wrapCallArgs (mainExecutor, swiftJobRunFuncDecl, 1 );
943
934
944
935
// Run first part synchronously
945
936
B.createApply (moduleLoc, swiftJobRunFunc, {}, {jobResult, mainExecutor});
0 commit comments