File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -331,6 +331,14 @@ bool OptimizeHopToExecutor::needsExecutor(SILInstruction *inst) {
331
331
if (auto *copy = dyn_cast<CopyAddrInst>(inst)) {
332
332
return isGlobalMemory (copy->getSrc ()) || isGlobalMemory (copy->getDest ());
333
333
}
334
+ // BeginBorrowInst and EndBorrowInst currently have
335
+ // MemoryBehavior::MayHaveSideEffects. Fixing that is tracked by
336
+ // rdar://111875527. These instructions only have effects in the sense of
337
+ // memory dependencies, which aren't relevant for hop_to_executor
338
+ // elimination.
339
+ if (isa<BeginBorrowInst>(inst) || isa<EndBorrowInst>(inst)) {
340
+ return false ;
341
+ }
334
342
return inst->mayReadOrWriteMemory ();
335
343
}
336
344
Original file line number Diff line number Diff line change @@ -278,3 +278,27 @@ bb0(%0 : @guaranteed $MyActor):
278
278
%r = tuple ()
279
279
return %r : $()
280
280
}
281
+
282
+ // CHECK-LABEL: sil [ossa] @handleBeginBorrow : {{.*}} {
283
+ // CHECK-NOT: hop_to_executor
284
+ // CHECK-LABEL: } // end sil function 'handleBeginBorrow'
285
+ sil [ossa] @handleBeginBorrow : $@convention(method) @async (@guaranteed MyActor) -> () {
286
+ bb0(%0 : @guaranteed $MyActor):
287
+ hop_to_executor %0 : $MyActor
288
+ %b = begin_borrow %0 : $MyActor
289
+ end_borrow %b : $MyActor
290
+ %r = tuple ()
291
+ return %r : $()
292
+ }
293
+
294
+ // CHECK-LABEL: sil [ossa] @handleEndBorrow : {{.*}} {
295
+ // CHECK-NOT: hop_to_executor
296
+ // CHECK-LABEL: } // end sil function 'handleEndBorrow'
297
+ sil [ossa] @handleEndBorrow : $@convention(method) @async (@guaranteed MyActor) -> () {
298
+ bb0(%0 : @guaranteed $MyActor):
299
+ %b = begin_borrow %0 : $MyActor
300
+ hop_to_executor %0 : $MyActor
301
+ end_borrow %b : $MyActor
302
+ %r = tuple ()
303
+ return %r : $()
304
+ }
You can’t perform that action at this time.
0 commit comments