Skip to content

Commit 76fd747

Browse files
Merge pull request #82510 from nate-chandler/rdar80334865
[IRGen] Sign these function pointers.
2 parents de6870e + c108d48 commit 76fd747

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

lib/IRGen/GenValueWitness.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,17 +1252,15 @@ static void addValueWitness(IRGenModule &IGM, ConstantStructBuilder &B,
12521252
if (auto *enumDecl = boundGenericCharacteristics->concreteType
12531253
.getEnumOrBoundGenericEnum())
12541254
if (IGM.getMetadataLayout(enumDecl).hasPayloadSizeOffset())
1255-
return B.add(llvm::ConstantExpr::getBitCast(
1256-
IGM.getGetMultiPayloadEnumTagSinglePayloadFn(), IGM.Int8PtrTy));
1255+
return addFunction(IGM.getGetMultiPayloadEnumTagSinglePayloadFn());
12571256
goto standard;
12581257
}
12591258
case ValueWitness::StoreEnumTagSinglePayload: {
12601259
if (boundGenericCharacteristics)
12611260
if (auto *enumDecl = boundGenericCharacteristics->concreteType
12621261
.getEnumOrBoundGenericEnum())
12631262
if (IGM.getMetadataLayout(enumDecl).hasPayloadSizeOffset())
1264-
return B.add(llvm::ConstantExpr::getBitCast(
1265-
IGM.getStoreMultiPayloadEnumTagSinglePayloadFn(), IGM.Int8PtrTy));
1263+
return addFunction(IGM.getStoreMultiPayloadEnumTagSinglePayloadFn());
12661264
goto standard;
12671265
}
12681266

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %swift -prespecialize-generic-metadata -target %module-target-future -emit-irgen %s | %IRGenFileCheck %s
2+
3+
// REQUIRES: CPU=arm64e
4+
5+
public enum R<X> {
6+
case a(X)
7+
case b(Any)
8+
}
9+
10+
@inline(never)
11+
func consume<T>(_ t: T) {}
12+
13+
// CHECK: @"$s4main1ROySiGWV" = {{.*}}%swift.enum_vwtable {
14+
// : ptr @"$s4main1ROwCP.ptrauth.1",
15+
// : ptr @"$s4main1ROwxx.ptrauth.2",
16+
// : ptr @"$s4main1ROwcp.ptrauth.3",
17+
// : ptr @"$s4main1ROwca.ptrauth.4",
18+
// : ptr @"$s4main1ROwtk.ptrauth.5",
19+
// : ptr @"$s4main1ROwta.ptrauth.6",
20+
// CHECK-SAME: ptr @swift_getMultiPayloadEnumTagSinglePayload.ptrauth,
21+
// CHECK-SAME: ptr @swift_storeMultiPayloadEnumTagSinglePayload.ptrauth,
22+
// : i64 33,
23+
// : i64 40,
24+
// : i32 2293767,
25+
// : i32 254,
26+
// : ptr @"$s4main1ROwug.ptrauth.7",
27+
// : ptr @"$s4main1ROwup.ptrauth.8",
28+
// : ptr @"$s4main1ROwui.ptrauth.9"
29+
// : }
30+
consume(R<Int>.self)

0 commit comments

Comments
 (0)