File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -1177,6 +1177,9 @@ namespace SpecialPointerAuthDiscriminators {
11771177
11781178 // / Resilient class stub initializer callback
11791179 const uint16_t ResilientClassStubInitCallback = 0xC671 ;
1180+
1181+ // / Actor enqueue(partialTask:).
1182+ const uint16_t ActorEnqueuePartialTask = 0x8f3d ;
11801183}
11811184
11821185// / The number of arguments that will be passed directly to a generic
Original file line number Diff line number Diff line change @@ -400,6 +400,17 @@ PointerAuthEntity::getDeclDiscriminator(IRGenModule &IGM) const {
400400 assert (!constant.isForeign &&
401401 " discriminator for foreign declaration not supported yet!" );
402402
403+ // Special case: methods that are witnesses to Actor.enqueue(partialTask:)
404+ // have their own descriminator, which is shared across all actor classes.
405+ if (constant.hasFuncDecl ()) {
406+ auto func = dyn_cast<FuncDecl>(constant.getFuncDecl ());
407+ if (func->isActorEnqueuePartialTaskWitness ()) {
408+ cache = IGM.getSize (
409+ Size (SpecialPointerAuthDiscriminators::ActorEnqueuePartialTask));
410+ return cache;
411+ }
412+ }
413+
403414 auto mangling = constant.mangle ();
404415 cache = getDiscriminatorForString (IGM, mangling);
405416 return cache;
Original file line number Diff line number Diff line change 1+ // RUN: %swift -swift-version 5 -target arm64e-apple-macos11.0 -parse-stdlib %s -emit-ir -disable-llvm-optzns -enable-experimental-concurrency -o - | %FileCheck %s
2+
3+ // REQUIRES: CODEGENERATOR=ARM
4+ // REQUIRES: concurrency
5+ // REQUIRES: CPU=arm64e
6+ // REQUIRES: OS=macosx
7+
8+ import _Concurrency
9+ import Swift
10+
11+ public actor class A1 {
12+ var x : Int = 17
13+ }
14+
15+ open actor class A3< T> : Actor {
16+ open func f( ) { }
17+ }
18+
19+ // enqueue(partialTask:) has the same discriminator across all classes.
20+ // CHECK: s4main2A1C7enqueue11partialTasky12_Concurrency012PartialAsyncE0V_tF.ptrauth{{.*}}i64 36669
21+
22+ // CHECK: @"$s4main2A3CyxG12_Concurrency5ActorAaeFP7enqueue11partialTaskyAE012PartialAsyncG0V_tFTW"
23+ // CHECK-NOT: ret void
24+ // CHECK: call i64 @llvm.ptrauth.blend.i64(i64 %{{[0-9]+}}, i64 36669)
You can’t perform that action at this time.
0 commit comments