Skip to content

Commit 893d28c

Browse files
committed
[IRGen] Signed parent async context.
1 parent 5261c31 commit 893d28c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/IRGen/IRGenFunction.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,13 @@ void IRGenFunction::emitGetAsyncContinuation(SILType resumeTy,
564564
// TODO: add lifetime with matching lifetime in await_async_continuation
565565
auto contResumeAddr =
566566
Builder.CreateStructGEP(continuationContext.getAddress(), 0);
567-
Builder.CreateStore(getAsyncContext(),
567+
llvm::Value *asyncContextValue = getAsyncContext();
568+
if (auto schema = IGM.getOptions().PointerAuth.AsyncContextParent) {
569+
auto authInfo = PointerAuthInfo::emit(*this, schema, contResumeAddr,
570+
PointerAuthEntity());
571+
asyncContextValue = emitPointerAuthSign(*this, asyncContextValue, authInfo);
572+
}
573+
Builder.CreateStore(asyncContextValue,
568574
Address(contResumeAddr, pointerAlignment));
569575
auto contErrResultAddr =
570576
Builder.CreateStructGEP(continuationContext.getAddress(), 2);

test/IRGen/async/get_async_continuation.sil

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ bb0:
2727
// Initialize the async continuation context.
2828
// CHECK: [[context_addr:%.*]] = getelementptr inbounds %swift.async_continuation_context, %swift.async_continuation_context* [[cont_context]], i32 0, i32 0
2929
// CHECK: [[ctxt:%.*]] = load %swift.context*, %swift.context** [[ctxt_addr]]
30-
// CHECK: store %swift.context* [[ctxt]], %swift.context** [[context_addr]]
30+
31+
// CHECK-arm64e: [[ctxt_addr_int:%[0-9]+]] = ptrtoint %swift.context** [[context_addr]] to i64
32+
// CHECK-arm64e: [[ptrauth_blend:%[0-9]+]] = call i64 @llvm.ptrauth.blend.i64(i64 [[ctxt_addr_int]], i64 48546)
33+
// CHECK-arm64e: [[ctxt_int:%[0-9]+]] = ptrtoint %swift.context* [[ctxt]] to i64
34+
// CHECK-arm64e: [[signed_int:%[0-9]+]] = call i64 @llvm.ptrauth.sign.i64(i64 [[ctxt_int]], i32 2, i64 [[ptrauth_blend]])
35+
// CHECK-arm64e: [[signed_ctxt:%[0-9]+]] = inttoptr i64 [[signed_int]] to %swift.context*
36+
// CHECK-arm64e: store %swift.context* [[signed_ctxt]], %swift.context** [[context_addr]]
37+
// CHECK-x86_64: store %swift.context* [[ctxt]], %swift.context** [[context_addr]]
38+
3139
// CHECK: [[error_addr:%.*]] = getelementptr inbounds %swift.async_continuation_context, %swift.async_continuation_context* [[cont_context]], i32 0, i32 2
3240
// CHECK: store %swift.error* null, %swift.error** [[error_addr]]
3341
// CHECK: [[result_addr:%.*]] = getelementptr inbounds %swift.async_continuation_context, %swift.async_continuation_context* [[cont_context]], i32 0, i32 3

0 commit comments

Comments
 (0)