@@ -1205,8 +1205,9 @@ class IRGenSILFunction :
12051205 // SIL instruction lowering
12061206 // ===--------------------------------------------------------------------===//
12071207
1208- void visitSILBasicBlock (SILBasicBlock *BB );
1208+ bool shouldUseDispatchThunk (SILDeclRef method );
12091209
1210+ void visitSILBasicBlock (SILBasicBlock *BB);
12101211 void emitErrorResultVar (CanSILFunctionType FnTy,
12111212 SILResultInfo ErrorInfo,
12121213 DebugValueInst *DbgValue);
@@ -8414,28 +8415,17 @@ void IRGenSILFunction::visitObjCSuperMethodInst(swift::ObjCSuperMethodInst *i) {
84148415 /* startAtSuper=*/ true );
84158416}
84168417
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) {
84288419 AccessLevel methodAccess = method.getDecl ()->getEffectiveAccess ();
84298420 auto *classDecl = cast<ClassDecl>(method.getDecl ()->getDeclContext ());
84308421 bool shouldUseDispatchThunk = false ;
84318422 // Because typechecking for the debugger has more lax rules, check the access
84328423 // level of the getter to decide whether to use a dispatch thunk for the
84338424 // debugger.
8434- bool shouldUseDispatchThunkIfInDebugger =
8435- !classDecl->getASTContext ().LangOpts .DebuggerSupport ||
8436- methodAccess == AccessLevel::Public;
8425+ bool inDebugger = classDecl->getASTContext ().LangOpts .DebuggerSupport ;
8426+ bool shouldUseDispatchThunkIfInDebugger = methodAccess >= AccessLevel::Public;
84378427 if (IGM.hasResilientMetadata (classDecl, ResilienceExpansion::Maximal) &&
8438- shouldUseDispatchThunkIfInDebugger) {
8428+ (!inDebugger || shouldUseDispatchThunkIfInDebugger) ) {
84398429 shouldUseDispatchThunk = true ;
84408430 } else if (IGM.getOptions ().VirtualFunctionElimination ) {
84418431 // For VFE, use a thunk if the target class is in another module. This
@@ -8452,9 +8442,22 @@ void IRGenSILFunction::visitClassMethodInst(swift::ClassMethodInst *i) {
84528442 shouldUseDispatchThunk =
84538443 classDecl->getModuleContext () != IGM.getSwiftModule ();
84548444 }
8445+ return shouldUseDispatchThunk;
8446+ }
84558447
8456- if (shouldUseDispatchThunk) {
8457- llvm::Constant *fnPtr = IGM.getAddrOfDispatchThunk (method, NotForDefinition);
8448+ void IRGenSILFunction::visitClassMethodInst (swift::ClassMethodInst *i) {
8449+ assert (!i->getMember ().isForeign );
8450+
8451+ Explosion base = getLoweredExplosion (i->getOperand ());
8452+ llvm::Value *baseValue = base.claimNext ();
8453+
8454+ SILDeclRef method = i->getMember ().getOverriddenVTableEntry ();
8455+ PrettyStackTraceSILDeclRef entry (" lowering class method call to" , method);
8456+
8457+ auto methodType = i->getType ().castTo <SILFunctionType>();
8458+ if (shouldUseDispatchThunk (method)) {
8459+ llvm::Constant *fnPtr =
8460+ IGM.getAddrOfDispatchThunk (method, NotForDefinition);
84588461
84598462 if (methodType->isAsync ()) {
84608463 auto *fnPtrType = fnPtr->getType ();
0 commit comments