@@ -1823,9 +1823,15 @@ static llvm::GlobalVariable *getChainEntryForDynamicReplacement(
1823
1823
IGM.DynamicReplacementLinkEntryTy , linkEntry, indices);
1824
1824
bool isAsyncFunction =
1825
1825
entity.hasSILFunction () && entity.getSILFunction ()->isAsync ();
1826
+ bool isCalleeAllocatedCoroutine =
1827
+ entity.hasSILFunction () && entity.getSILFunction ()
1828
+ ->getLoweredFunctionType ()
1829
+ ->isCalleeAllocatedCoroutine ();
1826
1830
auto &schema =
1827
1831
isAsyncFunction
1828
1832
? IGM.getOptions ().PointerAuth .AsyncSwiftDynamicReplacements
1833
+ : isCalleeAllocatedCoroutine
1834
+ ? IGM.getOptions ().PointerAuth .CoroSwiftDynamicReplacements
1829
1835
: IGM.getOptions ().PointerAuth .SwiftDynamicReplacements ;
1830
1836
assert (entity.hasSILFunction () || entity.isOpaqueTypeDescriptorAccessor ());
1831
1837
auto authEntity = entity.hasSILFunction ()
@@ -2945,8 +2951,14 @@ static llvm::GlobalVariable *createGlobalForDynamicReplacementFunctionKey(
2945
2951
B.addRelativeAddress (linkEntry);
2946
2952
bool isAsyncFunction =
2947
2953
keyEntity.hasSILFunction () && keyEntity.getSILFunction ()->isAsync ();
2954
+ bool isCalleeAllocatedCoroutine =
2955
+ keyEntity.hasSILFunction () && keyEntity.getSILFunction ()
2956
+ ->getLoweredFunctionType ()
2957
+ ->isCalleeAllocatedCoroutine ();
2948
2958
auto schema = isAsyncFunction
2949
2959
? IGM.getOptions ().PointerAuth .AsyncSwiftDynamicReplacements
2960
+ : isCalleeAllocatedCoroutine
2961
+ ? IGM.getOptions ().PointerAuth .CoroSwiftDynamicReplacements
2950
2962
: IGM.getOptions ().PointerAuth .SwiftDynamicReplacements ;
2951
2963
if (schema) {
2952
2964
assert (keyEntity.hasSILFunction () ||
@@ -2957,7 +2969,9 @@ static llvm::GlobalVariable *createGlobalForDynamicReplacementFunctionKey(
2957
2969
B.addInt32 ((uint32_t )PointerAuthInfo::getOtherDiscriminator (IGM, schema,
2958
2970
authEntity)
2959
2971
->getZExtValue () |
2960
- ((uint32_t )isAsyncFunction ? 0x10000 : 0x0 ));
2972
+ ((uint32_t )isAsyncFunction ? 0x10000
2973
+ : isCalleeAllocatedCoroutine ? 0x20000
2974
+ : 0x0 ));
2961
2975
} else
2962
2976
B.addInt32 (0 );
2963
2977
B.finishAndSetAsInitializer (key);
@@ -3009,6 +3023,8 @@ void IRGenModule::createReplaceableProlog(IRGenFunction &IGF, SILFunction *f) {
3009
3023
3010
3024
auto &schema = f->isAsync ()
3011
3025
? getOptions ().PointerAuth .AsyncSwiftDynamicReplacements
3026
+ : f->getLoweredFunctionType ()->isCalleeAllocatedCoroutine ()
3027
+ ? getOptions ().PointerAuth .CoroSwiftDynamicReplacements
3012
3028
: getOptions ().PointerAuth .SwiftDynamicReplacements ;
3013
3029
llvm::Value *ReplFn = nullptr , *hasReplFn = nullptr ;
3014
3030
@@ -3227,9 +3243,15 @@ static void emitDynamicallyReplaceableThunk(IRGenModule &IGM,
3227
3243
forwardedArgs.push_back (&arg);
3228
3244
bool isAsyncFunction =
3229
3245
keyEntity.hasSILFunction () && keyEntity.getSILFunction ()->isAsync ();
3246
+ bool isCalleeAllocatedCoroutine =
3247
+ keyEntity.hasSILFunction () && keyEntity.getSILFunction ()
3248
+ ->getLoweredFunctionType ()
3249
+ ->isCalleeAllocatedCoroutine ();
3230
3250
auto &schema =
3231
3251
isAsyncFunction
3232
3252
? IGM.getOptions ().PointerAuth .AsyncSwiftDynamicReplacements
3253
+ : isCalleeAllocatedCoroutine
3254
+ ? IGM.getOptions ().PointerAuth .CoroSwiftDynamicReplacements
3233
3255
: IGM.getOptions ().PointerAuth .SwiftDynamicReplacements ;
3234
3256
assert (keyEntity.hasSILFunction () ||
3235
3257
keyEntity.isOpaqueTypeDescriptorAccessor ());
@@ -3356,6 +3378,8 @@ void IRGenModule::emitDynamicReplacementOriginalFunctionThunk(SILFunction *f) {
3356
3378
3357
3379
auto &schema = f->isAsync ()
3358
3380
? getOptions ().PointerAuth .AsyncSwiftDynamicReplacements
3381
+ : f->getLoweredFunctionType ()->isCalleeAllocatedCoroutine ()
3382
+ ? getOptions ().PointerAuth .CoroSwiftDynamicReplacements
3359
3383
: getOptions ().PointerAuth .SwiftDynamicReplacements ;
3360
3384
auto authInfo = PointerAuthInfo::emit (
3361
3385
IGF, schema, fnPtrAddr,
0 commit comments