Skip to content

Commit 4abb570

Browse files
committed
[IRGen] Stop using "extended" type encodings where not supported
These are only used in two places in the Apple Objective-C runtime: - A protocol's "extended method types" list - Block type descriptors We were using them when dynamically registering a protocol with the Objective-C runtime, but that's just expecting "normal" types; the "extended method types" list is never present in such a protocol.
1 parent 29e4c67 commit 4abb570

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
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: 3 additions & 7 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
@@ -392,8 +389,7 @@ class ObjCProtocolInitializerVisitor
392389

393390
void visitAbstractFunctionDecl(AbstractFunctionDecl *method) {
394391
llvm::Constant *name, *imp, *types;
395-
emitObjCMethodDescriptorParts(IGM, method, /*extended*/true,
396-
/*concrete*/false,
392+
emitObjCMethodDescriptorParts(IGM, method, /*concrete*/false,
397393
name, types, imp);
398394

399395
// When generating JIT'd code, we need to call sel_registerName() to force

lib/IRGen/GenObjC.cpp

Lines changed: 3 additions & 6 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) {
@@ -1315,10 +1314,8 @@ void irgen::emitObjCMethodDescriptor(IRGenModule &IGM,
13151314
ConstantArrayBuilder &descriptors,
13161315
AbstractFunctionDecl *method) {
13171316
llvm::Constant *selectorRef, *atEncoding, *impl;
1318-
auto silFn = emitObjCMethodDescriptorParts(IGM, method,
1319-
/*extended*/ false,
1320-
/*concrete*/ true,
1321-
selectorRef, atEncoding, impl);
1317+
auto silFn = emitObjCMethodDescriptorParts(IGM, method, /*concrete*/ true,
1318+
selectorRef, atEncoding, impl);
13221319
buildMethodDescriptor(descriptors, selectorRef, atEncoding, impl);
13231320

13241321
if (silFn && silFn->hasObjCReplacement()) {

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,

0 commit comments

Comments
 (0)