@@ -1205,8 +1205,9 @@ class IRGenSILFunction :
1205
1205
// SIL instruction lowering
1206
1206
// ===--------------------------------------------------------------------===//
1207
1207
1208
- void visitSILBasicBlock (SILBasicBlock *BB );
1208
+ bool shouldUseDispatchThunk (SILDeclRef method );
1209
1209
1210
+ void visitSILBasicBlock (SILBasicBlock *BB);
1210
1211
void emitErrorResultVar (CanSILFunctionType FnTy,
1211
1212
SILResultInfo ErrorInfo,
1212
1213
DebugValueInst *DbgValue);
@@ -8414,17 +8415,7 @@ void IRGenSILFunction::visitObjCSuperMethodInst(swift::ObjCSuperMethodInst *i) {
8414
8415
/* startAtSuper=*/ true );
8415
8416
}
8416
8417
8417
- void IRGenSILFunction::visitClassMethodInst (swift::ClassMethodInst *i) {
8418
- assert (!i->getMember ().isForeign );
8419
-
8420
- Explosion base = getLoweredExplosion (i->getOperand ());
8421
- llvm::Value *baseValue = base.claimNext ();
8422
-
8423
- SILDeclRef method = i->getMember ().getOverriddenVTableEntry ();
8424
- PrettyStackTraceSILDeclRef entry (" lowering class method call to" , method);
8425
-
8426
- auto methodType = i->getType ().castTo <SILFunctionType>();
8427
-
8418
+ bool IRGenSILFunction::shouldUseDispatchThunk (SILDeclRef method) {
8428
8419
AccessLevel methodAccess = method.getDecl ()->getEffectiveAccess ();
8429
8420
auto *classDecl = cast<ClassDecl>(method.getDecl ()->getDeclContext ());
8430
8421
bool shouldUseDispatchThunk = false ;
@@ -8452,9 +8443,22 @@ void IRGenSILFunction::visitClassMethodInst(swift::ClassMethodInst *i) {
8452
8443
shouldUseDispatchThunk =
8453
8444
classDecl->getModuleContext () != IGM.getSwiftModule ();
8454
8445
}
8446
+ return shouldUseDispatchThunk;
8447
+ }
8455
8448
8456
- if (shouldUseDispatchThunk) {
8457
- llvm::Constant *fnPtr = IGM.getAddrOfDispatchThunk (method, NotForDefinition);
8449
+ void IRGenSILFunction::visitClassMethodInst (swift::ClassMethodInst *i) {
8450
+ assert (!i->getMember ().isForeign );
8451
+
8452
+ Explosion base = getLoweredExplosion (i->getOperand ());
8453
+ llvm::Value *baseValue = base.claimNext ();
8454
+
8455
+ SILDeclRef method = i->getMember ().getOverriddenVTableEntry ();
8456
+ PrettyStackTraceSILDeclRef entry (" lowering class method call to" , method);
8457
+
8458
+ auto methodType = i->getType ().castTo <SILFunctionType>();
8459
+ if (shouldUseDispatchThunk (method)) {
8460
+ llvm::Constant *fnPtr =
8461
+ IGM.getAddrOfDispatchThunk (method, NotForDefinition);
8458
8462
8459
8463
if (methodType->isAsync ()) {
8460
8464
auto *fnPtrType = fnPtr->getType ();
0 commit comments