Skip to content

Commit 56831e1

Browse files
authored
Merge pull request #20559 from jrose-apple/sub-rosa (#21181)
[IRGen] Generate proper type descriptors for ObjC subscript accessors https://bugs.swift.org/browse/SR-8356 (cherry picked from commit b060166)
1 parent dba641c commit 56831e1

File tree

6 files changed

+130
-35
lines changed

6 files changed

+130
-35
lines changed

lib/IRGen/GenClass.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ namespace {
16501650
}
16511651

16521652
llvm::Constant *buildOptExtendedMethodTypes() {
1653-
if (!isBuildingProtocol()) return null();
1653+
assert(isBuildingProtocol());
16541654

16551655
ConstantInitBuilder builder(IGM);
16561656
auto array = builder.beginArray();
@@ -1670,6 +1670,8 @@ namespace {
16701670

16711671
void buildExtMethodTypes(ConstantArrayBuilder &array,
16721672
ArrayRef<MethodDescriptor> methods) {
1673+
assert(isBuildingProtocol());
1674+
16731675
for (auto descriptor : methods) {
16741676
assert(descriptor.getKind() == MethodDescriptor::Kind::Method &&
16751677
"cannot emit descriptor for non-method");

lib/IRGen/GenDecl.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ class CategoryInitializerVisitor
189189
return;
190190

191191
llvm::Constant *name, *imp, *types;
192-
emitObjCMethodDescriptorParts(IGM, method,
193-
/*extended*/false,
194-
/*concrete*/true,
192+
emitObjCMethodDescriptorParts(IGM, method, /*concrete*/true,
195193
name, types, imp);
196194

197195
// When generating JIT'd code, we need to call sel_registerName() to force
@@ -215,8 +213,7 @@ class CategoryInitializerVisitor
215213
void visitConstructorDecl(ConstructorDecl *constructor) {
216214
if (!requiresObjCMethodDescriptor(constructor)) return;
217215
llvm::Constant *name, *imp, *types;
218-
emitObjCMethodDescriptorParts(IGM, constructor, /*extended*/false,
219-
/*concrete*/true,
216+
emitObjCMethodDescriptorParts(IGM, constructor, /*concrete*/true,
220217
name, types, imp);
221218

222219
// When generating JIT'd code, we need to call sel_registerName() to force
@@ -391,9 +388,13 @@ class ObjCProtocolInitializerVisitor
391388
void visitMissingMemberDecl(MissingMemberDecl *placeholder) {}
392389

393390
void visitAbstractFunctionDecl(AbstractFunctionDecl *method) {
391+
if (isa<AccessorDecl>(method)) {
392+
// Accessors are handled as part of their AbstractStorageDecls.
393+
return;
394+
}
395+
394396
llvm::Constant *name, *imp, *types;
395-
emitObjCMethodDescriptorParts(IGM, method, /*extended*/true,
396-
/*concrete*/false,
397+
emitObjCMethodDescriptorParts(IGM, method, /*concrete*/false,
397398
name, types, imp);
398399

399400
// When generating JIT'd code, we need to call sel_registerName() to force
@@ -438,7 +439,8 @@ class ObjCProtocolInitializerVisitor
438439
Builder.CreateCall(protocol_addMethodDescription, getterArgs);
439440

440441
if (prop->isSettable(nullptr)) {
441-
emitObjCSetterDescriptorParts(IGM, prop, name, types, imp);
442+
emitObjCSetterDescriptorParts(IGM, prop,
443+
name, types, imp);
442444
sel = Builder.CreateCall(IGM.getObjCSelRegisterNameFn(), name);
443445
llvm::Value *setterArgs[] = {
444446
NewProto, sel, types,

lib/IRGen/GenObjC.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,6 @@ static llvm::Constant *getObjCEncodingForMethodType(IRGenModule &IGM,
11241124
/// type encoding, and IMP pointer.
11251125
SILFunction *irgen::emitObjCMethodDescriptorParts(IRGenModule &IGM,
11261126
AbstractFunctionDecl *method,
1127-
bool extendedEncoding,
11281127
bool concrete,
11291128
llvm::Constant *&selectorRef,
11301129
llvm::Constant *&atEncoding,
@@ -1138,7 +1137,7 @@ SILFunction *irgen::emitObjCMethodDescriptorParts(IRGenModule &IGM,
11381137
/// the return type @encoding and every parameter type @encoding, glued with
11391138
/// numbers that used to represent stack offsets for each of these elements.
11401139
CanSILFunctionType methodType = getObjCMethodType(IGM, method);
1141-
atEncoding = getObjCEncodingForMethodType(IGM, methodType, extendedEncoding);
1140+
atEncoding = getObjCEncodingForMethodType(IGM, methodType, /*extended*/false);
11421141

11431142
/// The third element is the method implementation pointer.
11441143
if (!concrete) {
@@ -1196,7 +1195,8 @@ SILFunction *irgen::emitObjCGetterDescriptorParts(IRGenModule &IGM,
11961195
llvm::Constant *&impl) {
11971196
Selector getterSel(subscript, Selector::ForGetter);
11981197
selectorRef = IGM.getAddrOfObjCMethodName(getterSel.str());
1199-
atEncoding = llvm::ConstantPointerNull::get(IGM.Int8PtrTy);
1198+
CanSILFunctionType methodTy = getObjCMethodType(IGM, subscript->getGetter());
1199+
atEncoding = getObjCEncodingForMethodType(IGM, methodTy, /*extended*/false);
12001200
SILFunction *silFn = nullptr;
12011201
impl = getObjCGetterPointer(IGM, subscript, silFn);
12021202
return silFn;
@@ -1271,7 +1271,8 @@ SILFunction *irgen::emitObjCSetterDescriptorParts(IRGenModule &IGM,
12711271

12721272
Selector setterSel(subscript, Selector::ForSetter);
12731273
selectorRef = IGM.getAddrOfObjCMethodName(setterSel.str());
1274-
atEncoding = llvm::ConstantPointerNull::get(IGM.Int8PtrTy);
1274+
CanSILFunctionType methodTy = getObjCMethodType(IGM, subscript->getSetter());
1275+
atEncoding = getObjCEncodingForMethodType(IGM, methodTy, /*extended*/false);
12751276
SILFunction *silFn = nullptr;
12761277
impl = getObjCSetterPointer(IGM, subscript, silFn);
12771278
return silFn;
@@ -1315,10 +1316,8 @@ void irgen::emitObjCMethodDescriptor(IRGenModule &IGM,
13151316
ConstantArrayBuilder &descriptors,
13161317
AbstractFunctionDecl *method) {
13171318
llvm::Constant *selectorRef, *atEncoding, *impl;
1318-
auto silFn = emitObjCMethodDescriptorParts(IGM, method,
1319-
/*extended*/ false,
1320-
/*concrete*/ true,
1321-
selectorRef, atEncoding, impl);
1319+
auto silFn = emitObjCMethodDescriptorParts(IGM, method, /*concrete*/ true,
1320+
selectorRef, atEncoding, impl);
13221321
buildMethodDescriptor(descriptors, selectorRef, atEncoding, impl);
13231322

13241323
if (silFn && silFn->hasObjCReplacement()) {
@@ -1382,8 +1381,8 @@ void irgen::emitObjCGetterDescriptor(IRGenModule &IGM,
13821381
ConstantArrayBuilder &descriptors,
13831382
AbstractStorageDecl *storage) {
13841383
llvm::Constant *selectorRef, *atEncoding, *impl;
1385-
auto *silFn = emitObjCGetterDescriptorParts(IGM, storage, selectorRef,
1386-
atEncoding, impl);
1384+
auto *silFn = emitObjCGetterDescriptorParts(IGM, storage,
1385+
selectorRef, atEncoding, impl);
13871386
buildMethodDescriptor(descriptors, selectorRef, atEncoding, impl);
13881387
if (silFn && silFn->hasObjCReplacement()) {
13891388
auto replacedSelector =
@@ -1396,8 +1395,8 @@ void irgen::emitObjCSetterDescriptor(IRGenModule &IGM,
13961395
ConstantArrayBuilder &descriptors,
13971396
AbstractStorageDecl *storage) {
13981397
llvm::Constant *selectorRef, *atEncoding, *impl;
1399-
auto *silFn = emitObjCSetterDescriptorParts(IGM, storage, selectorRef,
1400-
atEncoding, impl);
1398+
auto *silFn = emitObjCSetterDescriptorParts(IGM, storage,
1399+
selectorRef, atEncoding, impl);
14011400
buildMethodDescriptor(descriptors, selectorRef, atEncoding, impl);
14021401
if (silFn && silFn->hasObjCReplacement()) {
14031402
auto replacedSelector =

lib/IRGen/GenObjC.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ namespace irgen {
109109
/// method or constructor implementation.
110110
SILFunction *emitObjCMethodDescriptorParts(IRGenModule &IGM,
111111
AbstractFunctionDecl *method,
112-
bool extendedEncoding,
113112
bool concrete,
114113
llvm::Constant *&selectorRef,
115114
llvm::Constant *&atEncoding,

test/IRGen/objc_protocol_extended_method_types.swift

Lines changed: 97 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %build-irgen-test-overlays
33
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir | %FileCheck %s
4+
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir -use-jit | %FileCheck -check-prefix=CHECK-JIT %s
45

5-
// REQUIRES: CPU=x86_64
6+
// REQUIRES: OS=macosx
67
// REQUIRES: objc_interop
78

89
import Foundation
910

10-
// CHECK: [[INIT:@.*]] = private unnamed_addr constant [8 x i8] c"@16@0:8\00"
11-
// CHECK: [[NSNUMBER:@.*]] = private unnamed_addr constant [31 x i8] c"@\22NSNumber\2224@0:8@\22NSNumber\2216\00"
12-
// CHECK: [[NSMUTABLEARRAY_GET:@.*]] = private unnamed_addr constant [24 x i8] c"@\22NSMutableArray\2216@0:8\00"
13-
// CHECK: [[NSMUTABLEARRAY_SET:@.*]] = private unnamed_addr constant [27 x i8] c"v24@0:8@\22NSMutableArray\2216\00"
14-
// CHECK: [[SUBSCRIPT:@.*]] = private unnamed_addr constant [11 x i8] c"q24@0:8q16\00"
15-
// CHECK: [[NSSTRING:@.*]] = private unnamed_addr constant [31 x i8] c"@\22NSString\2224@0:8@\22NSString\2216\00"
16-
// CHECK: [[NSOBJECT:@.*]] = private unnamed_addr constant [31 x i8] c"@\22NSObject\2224@0:8@\22NSObject\2216\00"
17-
// CHECK: [[NSMUTABLESTRING:@.*]] = private unnamed_addr constant [28 x i8] c"v24@0:8@\22NSMutableString\2216\00"
11+
// CHECK-JIT-DAG: [[PROTOCOL_NAME:@.+]] = private unnamed_addr constant [45 x i8] c"_TtP35objc_protocol_extended_method_types1P_\00"
12+
13+
14+
// CHECK-DAG: [[INIT:@.*]] = private unnamed_addr constant [8 x i8] c"@16@0:8\00"
15+
// CHECK-DAG: [[NSNUMBER:@.*]] = private unnamed_addr constant [31 x i8] c"@\22NSNumber\2224@0:8@\22NSNumber\2216\00"
16+
// CHECK-DAG: [[NSMUTABLEARRAY_GET:@.*]] = private unnamed_addr constant [24 x i8] c"@\22NSMutableArray\2216@0:8\00"
17+
// CHECK-DAG: [[NSMUTABLEARRAY_SET:@.*]] = private unnamed_addr constant [27 x i8] c"v24@0:8@\22NSMutableArray\2216\00"
18+
// CHECK-DAG: [[SUBSCRIPT:@.*]] = private unnamed_addr constant [11 x i8] c"q24@0:8q16\00"
19+
// CHECK-DAG: [[NSSTRING:@.*]] = private unnamed_addr constant [31 x i8] c"@\22NSString\2224@0:8@\22NSString\2216\00"
20+
// CHECK-DAG: [[NSOBJECT:@.*]] = private unnamed_addr constant [31 x i8] c"@\22NSObject\2224@0:8@\22NSObject\2216\00"
21+
// CHECK-DAG: [[NSMUTABLESTRING:@.*]] = private unnamed_addr constant [28 x i8] c"v24@0:8@\22NSMutableString\2216\00"
22+
23+
// The JIT registration logic doesn't use extended types.
24+
// CHECK-JIT-DAG: [[TY_ID_ID:@.*]] = private unnamed_addr constant [11 x i8] c"@24@0:8@16\00"
25+
// CHECK-JIT-DAG: [[TY_VOID_ID:@.*]] = private unnamed_addr constant [11 x i8] c"v24@0:8@16\00"
26+
// CHECK-JIT-DAG: [[TY_ID:@.*]] = private unnamed_addr constant [8 x i8] c"@16@0:8\00"
27+
// CHECK-JIT-DAG: [[TY_INT_INT:@.*]] = private unnamed_addr constant [11 x i8] c"q24@0:8q16\00"
1828

1929
// CHECK-LABEL: @_PROTOCOL_METHOD_TYPES__TtP35objc_protocol_extended_method_types1P_ = private constant [16 x i8*] [
2030
// -- required instance methods:
@@ -75,3 +85,81 @@ import Foundation
7585
init()
7686
}
7787

88+
print(P.self)
89+
90+
// CHECK-JIT-LABEL: define private void @runtime_registration
91+
// CHECK-JIT: [[EXISTING_PROTOCOL:%.+]] = call %swift.protocol* @objc_getProtocol(i8* getelementptr inbounds ([45 x i8], [45 x i8]* [[PROTOCOL_NAME]], i64 0, i64 0))
92+
// CHECK-JIT: [[EXISTS:%.+]] = icmp eq %swift.protocol* [[EXISTING_PROTOCOL]], null
93+
// CHECK-JIT: br i1 [[EXISTS]], label %[[NEW_PROTOCOL_LABEL:[^ ]+]], label %[[EXISTING_PROTOCOL_LABEL:[^ ]+]]
94+
95+
// CHECK-JIT: [[EXISTING_PROTOCOL_LABEL]]:
96+
// CHECK-JIT: br label %[[FINISH_LABEL:[^ ]+]]
97+
98+
// CHECK-JIT: [[NEW_PROTOCOL_LABEL]]:
99+
// CHECK-JIT: [[NEW_PROTOCOL:%.+]] = call %swift.protocol* @objc_allocateProtocol(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @2, i64 0, i64 0))
100+
// -- requiredInstanceMethod:
101+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredInstanceMethod:)", i64 0, i64 0))
102+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), i8 1, i8 1)
103+
// -- optionalInstanceMethod:
104+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(optionalInstanceMethod:)", i64 0, i64 0))
105+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), i8 0, i8 1)
106+
// -- requiredClassMethod:
107+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredClassMethod:)", i64 0, i64 0))
108+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), i8 1, i8 0)
109+
// -- optionalClassMethod:
110+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(optionalClassMethod:)", i64 0, i64 0))
111+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_VOID_ID]], i64 0, i64 0), i8 0, i8 0)
112+
// -- requiredInstanceProperty
113+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredInstanceProperty)", i64 0, i64 0))
114+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), i8 1, i8 1)
115+
116+
// Make sure we don't emit storage accessors multiple times.
117+
// CHECK-JIT-NOT: requiredInstanceProperty
118+
119+
// -- setRequiredInstanceProperty:
120+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(setRequiredInstanceProperty:)", i64 0, i64 0))
121+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_VOID_ID]], i64 0, i64 0), i8 1, i8 1)
122+
123+
// Make sure we don't emit storage accessors multiple times.
124+
// CHECK-JIT-NOT: requiredInstanceProperty
125+
// CHECK-JIT-NOT: setRequiredInstanceProperty
126+
127+
// -- requiredROInstanceProperty
128+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredROInstanceProperty)", i64 0, i64 0))
129+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), i8 1, i8 1)
130+
// -- requiredInstanceMethod2:
131+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredInstanceMethod2:)", i64 0, i64 0))
132+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), i8 1, i8 1)
133+
// -- optionalInstanceMethod2:
134+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(optionalInstanceMethod2:)", i64 0, i64 0))
135+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), i8 0, i8 1)
136+
// -- requiredClassMethod2:
137+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredClassMethod2:)", i64 0, i64 0))
138+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID_ID]], i64 0, i64 0), i8 1, i8 0)
139+
// -- optionalClassMethod2:
140+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(optionalClassMethod2:)", i64 0, i64 0))
141+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_VOID_ID]], i64 0, i64 0), i8 0, i8 0)
142+
// -- requiredInstanceProperty2
143+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredInstanceProperty2)", i64 0, i64 0))
144+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), i8 1, i8 1)
145+
// -- setRequiredInstanceProperty2:
146+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(setRequiredInstanceProperty2:)", i64 0, i64 0))
147+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_VOID_ID]], i64 0, i64 0), i8 1, i8 1)
148+
// -- requiredROInstanceProperty2
149+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(requiredROInstanceProperty2)", i64 0, i64 0))
150+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), i8 1, i8 1)
151+
// -- objectAtIndexedSubscript:
152+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(objectAtIndexedSubscript:)", i64 0, i64 0))
153+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_INT_INT]], i64 0, i64 0), i8 1, i8 1)
154+
// -- init
155+
// CHECK-JIT: [[SELECTOR:%.+]] = call i8* @sel_registerName(i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @"\01L_selector_data(init)", i64 0, i64 0))
156+
// CHECK-JIT: call void @protocol_addMethodDescription(%swift.protocol* [[NEW_PROTOCOL]], i8* [[SELECTOR]], i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* [[TY_ID]], i64 0, i64 0), i8 1, i8 1)
157+
// CHECK-JIT: call void @objc_registerProtocol(%swift.protocol* [[NEW_PROTOCOL]])
158+
// CHECK-JIT: br label %[[FINISH_LABEL]]
159+
160+
// CHECK-JIT: [[FINISH_LABEL]]:
161+
// CHECK-JIT: [[RESOLVED_PROTOCOL:%.+]] = phi %swift.protocol* [ [[EXISTING_PROTOCOL]], %[[EXISTING_PROTOCOL_LABEL]] ], [ [[NEW_PROTOCOL]], %[[NEW_PROTOCOL_LABEL]] ]{{$}}
162+
// CHECK-JIT: store %swift.protocol* [[RESOLVED_PROTOCOL]], %swift.protocol** bitcast (i8** @"\01l_OBJC_PROTOCOL_REFERENCE_$__TtP35objc_protocol_extended_method_types1P_" to %swift.protocol**), align 8
163+
// CHECK-JIT: ret void
164+
// CHECK-JIT-NEXT: {{^}$}}
165+

0 commit comments

Comments
 (0)