File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -2715,6 +2715,18 @@ FunctionPointer::Kind irgen::classifyFunctionPointerKind(SILFunction *fn) {
2715
2715
2716
2716
return fn->getLoweredFunctionType ();
2717
2717
}
2718
+ // Async functions that end up with weak_odr or linkonce_odr linkage may not be
2719
+ // directly called because we need to preserve the connection between the
2720
+ // function's implementation and the function's context size in the async
2721
+ // function pointer data structure.
2722
+ static bool mayDirectlyCallAsync (SILFunction *fn) {
2723
+ if (fn->getLinkage () == SILLinkage::Shared ||
2724
+ fn->getLinkage () == SILLinkage::PublicNonABI) {
2725
+ return false ;
2726
+ }
2727
+
2728
+ return true ;
2729
+ }
2718
2730
2719
2731
void IRGenSILFunction::visitFunctionRefBaseInst (FunctionRefBaseInst *i) {
2720
2732
auto fn = i->getInitiallyReferencedFunction ();
@@ -2741,7 +2753,8 @@ void IRGenSILFunction::visitFunctionRefBaseInst(FunctionRefBaseInst *i) {
2741
2753
if (fpKind.isAsyncFunctionPointer ()) {
2742
2754
value = IGM.getAddrOfAsyncFunctionPointer (fn);
2743
2755
value = llvm::ConstantExpr::getBitCast (value, fnPtr->getType ());
2744
- secondaryValue = IGM.getAddrOfSILFunction (fn, NotForDefinition);
2756
+ secondaryValue = mayDirectlyCallAsync (fn) ?
2757
+ IGM.getAddrOfSILFunction (fn, NotForDefinition) : nullptr ;
2745
2758
2746
2759
// For ordinary sync functions and special async functions, produce
2747
2760
// only the direct address of the function. The runtime does not
You can’t perform that action at this time.
0 commit comments