File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -102,9 +102,19 @@ bool LowerHopToActor::processHop(HopToExecutorInst *hop) {
102
102
B.setInsertionPoint (hop);
103
103
B.setCurrentDebugScope (hop->getDebugScope ());
104
104
105
- // Get the dominating executor value for this actor, if available,
106
- // or else emit code to derive it.
107
- SILValue executor = emitGetExecutor (hop->getLoc (), actor, /* optional*/ true );
105
+ SILValue executor;
106
+ if (actor->getType ().is <BuiltinExecutorType>()) {
107
+ // IRGen expects an optional Builtin.Executor, not a Builtin.Executor
108
+ // but we can wrap it nicely
109
+ executor = B.createOptionalSome (
110
+ hop->getLoc (), actor,
111
+ SILType::getOptionalType (actor->getType ()));
112
+ } else {
113
+ // Get the dominating executor value for this actor, if available,
114
+ // or else emit code to derive it.
115
+ executor = emitGetExecutor (hop->getLoc (), actor, /* optional*/ true );
116
+ }
117
+ assert (executor && " executor not set" );
108
118
109
119
B.createHopToExecutor (hop->getLoc (), executor, /* mandatory*/ false );
110
120
Original file line number Diff line number Diff line change @@ -221,3 +221,22 @@ bb0(%0 : @guaranteed $CustomActor):
221
221
%r = tuple ()
222
222
return %r : $()
223
223
}
224
+
225
+ sil @get_raw_executor : $@convention(thin) () -> Builtin.Executor
226
+
227
+ // CHECK-LABEL: sil [ossa] @non_optional_executor :
228
+ sil [ossa] @non_optional_executor : $@async () -> () {
229
+ bb0:
230
+ // CHECK: bb0:
231
+ // CHECK: [[GET_RAW_EXECUTOR:%.*]] = function_ref @get_raw_executor
232
+ // CHECK-NEXT: [[EXECUTOR:%.*]] = apply [[GET_RAW_EXECUTOR]]()
233
+ // CHECK-NEXT: [[SOME:%.*]] = enum $Optional<Builtin.Executor>, #Optional.some!enumelt, [[EXECUTOR]] : $Builtin.Executor
234
+ // CHECK-NEXT: hop_to_executor [[SOME]] : $Optional<Builtin.Executor>
235
+ // CHECK-NEXT: [[RET:%.*]] = tuple ()
236
+ // CHECK-NEXT: return [[RET]] : $()
237
+ %0 = function_ref @get_raw_executor : $@convention(thin) () -> Builtin.Executor
238
+ %1 = apply %0() : $@convention(thin) () -> Builtin.Executor
239
+ hop_to_executor %1 : $Builtin.Executor
240
+ %r = tuple ()
241
+ return %r : $()
242
+ }
You can’t perform that action at this time.
0 commit comments