Skip to content

Commit 595aefd

Browse files
Merge pull request #65674 from aschwaighofer/opaque_ptrs_async_fun_ptr
IRGen: Fix lowering of static async function pointers under opaque-pointers
2 parents fd06d27 + 218e4f9 commit 595aefd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2761,11 +2761,14 @@ void IRGenSILFunction::visitFunctionRefBaseInst(FunctionRefBaseInst *i) {
27612761
// than indirecting through the async FP.
27622762
llvm::Constant *value;
27632763
llvm::Constant *secondaryValue;
2764+
bool useSignature = false;
27642765
if (fpKind.isAsyncFunctionPointer()) {
27652766
value = IGM.getAddrOfAsyncFunctionPointer(fn);
27662767
value = llvm::ConstantExpr::getBitCast(value, fnPtr->getType());
27672768
secondaryValue = mayDirectlyCallAsync(fn) ?
27682769
IGM.getAddrOfSILFunction(fn, NotForDefinition) : nullptr;
2770+
if (!secondaryValue)
2771+
useSignature = true;
27692772

27702773
// For ordinary sync functions and special async functions, produce
27712774
// only the direct address of the function. The runtime does not
@@ -2775,7 +2778,7 @@ void IRGenSILFunction::visitFunctionRefBaseInst(FunctionRefBaseInst *i) {
27752778
secondaryValue = nullptr;
27762779
}
27772780
FunctionPointer fp =
2778-
FunctionPointer::forDirect(fpKind, value, secondaryValue, sig);
2781+
FunctionPointer::forDirect(fpKind, value, secondaryValue, sig, useSignature);
27792782
// Update the foreign no-throw information if needed.
27802783
if (const auto *cd = fn->getClangDecl()) {
27812784
if (auto *cfd = dyn_cast<clang::FunctionDecl>(cd)) {

0 commit comments

Comments
 (0)