@@ -1823,9 +1823,15 @@ static llvm::GlobalVariable *getChainEntryForDynamicReplacement(
18231823 IGM.DynamicReplacementLinkEntryTy , linkEntry, indices);
18241824 bool isAsyncFunction =
18251825 entity.hasSILFunction () && entity.getSILFunction ()->isAsync ();
1826+ bool isCalleeAllocatedCoroutine =
1827+ entity.hasSILFunction () && entity.getSILFunction ()
1828+ ->getLoweredFunctionType ()
1829+ ->isCalleeAllocatedCoroutine ();
18261830 auto &schema =
18271831 isAsyncFunction
18281832 ? IGM.getOptions ().PointerAuth .AsyncSwiftDynamicReplacements
1833+ : isCalleeAllocatedCoroutine
1834+ ? IGM.getOptions ().PointerAuth .CoroSwiftDynamicReplacements
18291835 : IGM.getOptions ().PointerAuth .SwiftDynamicReplacements ;
18301836 assert (entity.hasSILFunction () || entity.isOpaqueTypeDescriptorAccessor ());
18311837 auto authEntity = entity.hasSILFunction ()
@@ -2945,8 +2951,14 @@ static llvm::GlobalVariable *createGlobalForDynamicReplacementFunctionKey(
29452951 B.addRelativeAddress (linkEntry);
29462952 bool isAsyncFunction =
29472953 keyEntity.hasSILFunction () && keyEntity.getSILFunction ()->isAsync ();
2954+ bool isCalleeAllocatedCoroutine =
2955+ keyEntity.hasSILFunction () && keyEntity.getSILFunction ()
2956+ ->getLoweredFunctionType ()
2957+ ->isCalleeAllocatedCoroutine ();
29482958 auto schema = isAsyncFunction
29492959 ? IGM.getOptions ().PointerAuth .AsyncSwiftDynamicReplacements
2960+ : isCalleeAllocatedCoroutine
2961+ ? IGM.getOptions ().PointerAuth .CoroSwiftDynamicReplacements
29502962 : IGM.getOptions ().PointerAuth .SwiftDynamicReplacements ;
29512963 if (schema) {
29522964 assert (keyEntity.hasSILFunction () ||
@@ -2957,7 +2969,9 @@ static llvm::GlobalVariable *createGlobalForDynamicReplacementFunctionKey(
29572969 B.addInt32 ((uint32_t )PointerAuthInfo::getOtherDiscriminator (IGM, schema,
29582970 authEntity)
29592971 ->getZExtValue () |
2960- ((uint32_t )isAsyncFunction ? 0x10000 : 0x0 ));
2972+ ((uint32_t )isAsyncFunction ? 0x10000
2973+ : isCalleeAllocatedCoroutine ? 0x20000
2974+ : 0x0 ));
29612975 } else
29622976 B.addInt32 (0 );
29632977 B.finishAndSetAsInitializer (key);
@@ -3009,6 +3023,8 @@ void IRGenModule::createReplaceableProlog(IRGenFunction &IGF, SILFunction *f) {
30093023
30103024 auto &schema = f->isAsync ()
30113025 ? getOptions ().PointerAuth .AsyncSwiftDynamicReplacements
3026+ : f->getLoweredFunctionType ()->isCalleeAllocatedCoroutine ()
3027+ ? getOptions ().PointerAuth .CoroSwiftDynamicReplacements
30123028 : getOptions ().PointerAuth .SwiftDynamicReplacements ;
30133029 llvm::Value *ReplFn = nullptr , *hasReplFn = nullptr ;
30143030
@@ -3227,9 +3243,15 @@ static void emitDynamicallyReplaceableThunk(IRGenModule &IGM,
32273243 forwardedArgs.push_back (&arg);
32283244 bool isAsyncFunction =
32293245 keyEntity.hasSILFunction () && keyEntity.getSILFunction ()->isAsync ();
3246+ bool isCalleeAllocatedCoroutine =
3247+ keyEntity.hasSILFunction () && keyEntity.getSILFunction ()
3248+ ->getLoweredFunctionType ()
3249+ ->isCalleeAllocatedCoroutine ();
32303250 auto &schema =
32313251 isAsyncFunction
32323252 ? IGM.getOptions ().PointerAuth .AsyncSwiftDynamicReplacements
3253+ : isCalleeAllocatedCoroutine
3254+ ? IGM.getOptions ().PointerAuth .CoroSwiftDynamicReplacements
32333255 : IGM.getOptions ().PointerAuth .SwiftDynamicReplacements ;
32343256 assert (keyEntity.hasSILFunction () ||
32353257 keyEntity.isOpaqueTypeDescriptorAccessor ());
@@ -3356,6 +3378,8 @@ void IRGenModule::emitDynamicReplacementOriginalFunctionThunk(SILFunction *f) {
33563378
33573379 auto &schema = f->isAsync ()
33583380 ? getOptions ().PointerAuth .AsyncSwiftDynamicReplacements
3381+ : f->getLoweredFunctionType ()->isCalleeAllocatedCoroutine ()
3382+ ? getOptions ().PointerAuth .CoroSwiftDynamicReplacements
33593383 : getOptions ().PointerAuth .SwiftDynamicReplacements ;
33603384 auto authInfo = PointerAuthInfo::emit (
33613385 IGF, schema, fnPtrAddr,
0 commit comments