mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #67237 from nate-chandler/opt_hop_to_executor/20230711/1
[OptimizeHopToExecutor] Don't hop for begin_borrow/end_borrow.
This commit is contained in:
@@ -331,6 +331,14 @@ bool OptimizeHopToExecutor::needsExecutor(SILInstruction *inst) {
|
||||
if (auto *copy = dyn_cast<CopyAddrInst>(inst)) {
|
||||
return isGlobalMemory(copy->getSrc()) || isGlobalMemory(copy->getDest());
|
||||
}
|
||||
// BeginBorrowInst and EndBorrowInst currently have
|
||||
// MemoryBehavior::MayHaveSideEffects. Fixing that is tracked by
|
||||
// rdar://111875527. These instructions only have effects in the sense of
|
||||
// memory dependencies, which aren't relevant for hop_to_executor
|
||||
// elimination.
|
||||
if (isa<BeginBorrowInst>(inst) || isa<EndBorrowInst>(inst)) {
|
||||
return false;
|
||||
}
|
||||
return inst->mayReadOrWriteMemory();
|
||||
}
|
||||
|
||||
|
||||
@@ -278,3 +278,27 @@ bb0(%0 : @guaranteed $MyActor):
|
||||
%r = tuple ()
|
||||
return %r : $()
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil [ossa] @handleBeginBorrow : {{.*}} {
|
||||
// CHECK-NOT: hop_to_executor
|
||||
// CHECK-LABEL: } // end sil function 'handleBeginBorrow'
|
||||
sil [ossa] @handleBeginBorrow : $@convention(method) @async (@guaranteed MyActor) -> () {
|
||||
bb0(%0 : @guaranteed $MyActor):
|
||||
hop_to_executor %0 : $MyActor
|
||||
%b = begin_borrow %0 : $MyActor
|
||||
end_borrow %b : $MyActor
|
||||
%r = tuple ()
|
||||
return %r : $()
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil [ossa] @handleEndBorrow : {{.*}} {
|
||||
// CHECK-NOT: hop_to_executor
|
||||
// CHECK-LABEL: } // end sil function 'handleEndBorrow'
|
||||
sil [ossa] @handleEndBorrow : $@convention(method) @async (@guaranteed MyActor) -> () {
|
||||
bb0(%0 : @guaranteed $MyActor):
|
||||
%b = begin_borrow %0 : $MyActor
|
||||
hop_to_executor %0 : $MyActor
|
||||
end_borrow %b : $MyActor
|
||||
%r = tuple ()
|
||||
return %r : $()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user