Skip to content

Commit d17c069

Browse files
committed
[Async CC] Auth'd AFP ptr of dynamically thin fn.
In irgen::getAsyncFunctionAndSize, in the case where the passed-in function has a thick representation but is dynamically thin, 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.
1 parent bbf5795 commit d17c069

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
@@ -1945,6 +1945,9 @@ std::pair<llvm::Value *, llvm::Value *> irgen::getAsyncFunctionAndSize(
19451945
{ // thin
19461946
IGF.Builder.emitBlock(thinBlock);
19471947
auto *ptr = functionPointer.getRawPointer();
1948+
if (auto authInfo = functionPointer.getAuthInfo()) {
1949+
ptr = emitPointerAuthAuth(IGF, ptr, authInfo);
1950+
}
19481951
auto *afpPtr =
19491952
IGF.Builder.CreateBitCast(ptr, IGF.IGM.AsyncFunctionPointerPtrTy);
19501953
if (emitFunction) {
@@ -1953,6 +1956,9 @@ std::pair<llvm::Value *, llvm::Value *> irgen::getAsyncFunctionAndSize(
19531956
Address(addrPtr, IGF.IGM.getPointerAlignment()), /*isFar*/ false,
19541957
/*expectedType*/ functionPointer.getFunctionType()->getPointerTo());
19551958
auto *fnPtr = IGF.Builder.CreateBitCast(uncastFnPtr, IGF.IGM.Int8PtrTy);
1959+
if (auto authInfo = functionPointer.getAuthInfo()) {
1960+
fnPtr = emitPointerAuthSign(IGF, fnPtr, authInfo);
1961+
}
19561962
fnPhiValues.push_back({thinBlock, fnPtr});
19571963
}
19581964
if (emitSize) {

0 commit comments

Comments
 (0)