@@ -3271,6 +3271,10 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
3271
3271
EI->getForwardingOwnershipKind () == OwnershipKind::Guaranteed,
3272
3272
" invalid forwarding ownership kind on tuple_extract instruction" );
3273
3273
3274
+ require (!EI->getStructDecl ()->isNonTrivialPtrAuth (),
3275
+ " Imported structs with ptrauth qualified fields should not be "
3276
+ " promoted to a value" );
3277
+
3274
3278
if (EI->getModule ().getStage () != SILStage::Lowered) {
3275
3279
SILType loweredFieldTy = operandTy.getFieldType (
3276
3280
EI->getField (), F.getModule (), F.getTypeExpansionContext ());
@@ -3318,6 +3322,14 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
3318
3322
require (EI->getField ()->getDeclContext () == sd,
3319
3323
" struct_element_addr field is not a member of the struct" );
3320
3324
3325
+ if (EI->getStructDecl ()->isNonTrivialPtrAuth ()) {
3326
+ for (auto *use : EI->getUses ()) {
3327
+ auto *bai = dyn_cast<BeginAccessInst>(use->getUser ());
3328
+ require (bai && bai->getEnforcement () == SILAccessEnforcement::Signed,
3329
+ " Access to ptrauth qualified fields should be scoped with "
3330
+ " begin_access [signed]/end_access" );
3331
+ }
3332
+ }
3321
3333
if (EI->getModule ().getStage () != SILStage::Lowered) {
3322
3334
SILType loweredFieldTy = operandTy.getFieldType (
3323
3335
EI->getField (), F.getModule (), F.getTypeExpansionContext ());
0 commit comments