Skip to content

Commit 0d93b8d

Browse files
committed
[Async CC] Auth'd AFP ptr to load ptr from FunctionPointer.
In FunctionPointer::getPointer, in the case that the FunctionPointer is actually a pointer to an AsyncFunctionPointer struct, the relative address of the function must be loaded from the AsyncFunctionPointer struct. Doing so requires authentication that pointer to the AsyncFunctionPointer struct. Here, that authentication is done.
1 parent d17c069 commit 0d93b8d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4539,18 +4539,25 @@ llvm::Value *FunctionPointer::getPointer(IRGenFunction &IGF) const {
45394539
return Value;
45404540
case KindTy::Value::AsyncFunctionPointer: {
45414541
if (!isFunctionPointerWithoutContext) {
4542+
auto *fnPtr = Value;
4543+
if (auto authInfo = AuthInfo) {
4544+
fnPtr = emitPointerAuthAuth(IGF, fnPtr, authInfo);
4545+
}
45424546
auto *descriptorPtr =
4543-
IGF.Builder.CreateBitCast(Value, IGF.IGM.AsyncFunctionPointerPtrTy);
4547+
IGF.Builder.CreateBitCast(fnPtr, IGF.IGM.AsyncFunctionPointerPtrTy);
45444548
auto *addrPtr = IGF.Builder.CreateStructGEP(descriptorPtr, 0);
4545-
return IGF.emitLoadOfRelativePointer(
4549+
auto *result = IGF.emitLoadOfRelativePointer(
45464550
Address(addrPtr, IGF.IGM.getPointerAlignment()), /*isFar*/ false,
45474551
/*expectedType*/ getFunctionType()->getPointerTo());
4552+
if (auto authInfo = AuthInfo) {
4553+
result = emitPointerAuthSign(IGF, result, authInfo);
4554+
}
4555+
return result;
45484556
} else {
45494557
return IGF.Builder.CreateBitOrPointerCast(
45504558
Value, getFunctionType()->getPointerTo());
45514559
}
45524560
}
4553-
45544561
}
45554562
}
45564563

0 commit comments

Comments
 (0)