Skip to content

Commit eac9cfc

Browse files
committed
[Async CC] Auth'd AFP ptr of statically thin fn.
In irgen::getAsyncFunctionAndSize, in the case where the passed-in function has a thin representation, the pointer that is passed in is not actually a pointer to a function but instead a pointer to an AsyncFunctionPointer struct. To obtain the function pointer and size, fields must be loaded from this struct. However, in order to load these fields, that pointer to the AsyncFunctionPointer struct must itself first be authenticated. Here, that authentication is performed. Subsequently, the function pointer is again signed.
1 parent 5256697 commit eac9cfc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,6 +2039,9 @@ std::pair<llvm::Value *, llvm::Value *> irgen::getAsyncFunctionAndSize(
20392039
case SILFunctionTypeRepresentation::Closure:
20402040
case SILFunctionTypeRepresentation::Block: {
20412041
auto *ptr = functionPointer.getRawPointer();
2042+
if (auto authInfo = functionPointer.getAuthInfo()) {
2043+
ptr = emitPointerAuthAuth(IGF, ptr, authInfo);
2044+
}
20422045
auto *afpPtr =
20432046
IGF.Builder.CreateBitCast(ptr, IGF.IGM.AsyncFunctionPointerPtrTy);
20442047
llvm::Value *fn = nullptr;
@@ -2051,6 +2054,9 @@ std::pair<llvm::Value *, llvm::Value *> irgen::getAsyncFunctionAndSize(
20512054
Address(addrPtr, IGF.IGM.getPointerAlignment()), /*isFar*/ false,
20522055
/*expectedType*/ functionPointer.getFunctionType()->getPointerTo());
20532056
}
2057+
if (auto authInfo = functionPointer.getAuthInfo()) {
2058+
fn = emitPointerAuthSign(IGF, fn, authInfo);
2059+
}
20542060
}
20552061
llvm::Value *size = nullptr;
20562062
if (emitSize) {

0 commit comments

Comments
 (0)