Skip to content

[LLDB] Fix conditional to also support AccessLevel::Open #80698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1205,8 +1205,9 @@ class IRGenSILFunction :
// SIL instruction lowering
//===--------------------------------------------------------------------===//

void visitSILBasicBlock(SILBasicBlock *BB);
bool shouldUseDispatchThunk(SILDeclRef method);

void visitSILBasicBlock(SILBasicBlock *BB);
void emitErrorResultVar(CanSILFunctionType FnTy,
SILResultInfo ErrorInfo,
DebugValueInst *DbgValue);
Expand Down Expand Up @@ -8414,28 +8415,17 @@ void IRGenSILFunction::visitObjCSuperMethodInst(swift::ObjCSuperMethodInst *i) {
/*startAtSuper=*/true);
}

void IRGenSILFunction::visitClassMethodInst(swift::ClassMethodInst *i) {
assert(!i->getMember().isForeign);

Explosion base = getLoweredExplosion(i->getOperand());
llvm::Value *baseValue = base.claimNext();

SILDeclRef method = i->getMember().getOverriddenVTableEntry();
PrettyStackTraceSILDeclRef entry("lowering class method call to", method);

auto methodType = i->getType().castTo<SILFunctionType>();

bool IRGenSILFunction::shouldUseDispatchThunk(SILDeclRef method) {
AccessLevel methodAccess = method.getDecl()->getEffectiveAccess();
auto *classDecl = cast<ClassDecl>(method.getDecl()->getDeclContext());
bool shouldUseDispatchThunk = false;
// Because typechecking for the debugger has more lax rules, check the access
// level of the getter to decide whether to use a dispatch thunk for the
// debugger.
bool shouldUseDispatchThunkIfInDebugger =
!classDecl->getASTContext().LangOpts.DebuggerSupport ||
methodAccess == AccessLevel::Public;
bool inDebugger = classDecl->getASTContext().LangOpts.DebuggerSupport;
bool shouldUseDispatchThunkIfInDebugger = methodAccess >= AccessLevel::Public;
if (IGM.hasResilientMetadata(classDecl, ResilienceExpansion::Maximal) &&
shouldUseDispatchThunkIfInDebugger) {
(!inDebugger || shouldUseDispatchThunkIfInDebugger)) {
shouldUseDispatchThunk = true;
} else if (IGM.getOptions().VirtualFunctionElimination) {
// For VFE, use a thunk if the target class is in another module. This
Expand All @@ -8452,9 +8442,22 @@ void IRGenSILFunction::visitClassMethodInst(swift::ClassMethodInst *i) {
shouldUseDispatchThunk =
classDecl->getModuleContext() != IGM.getSwiftModule();
}
return shouldUseDispatchThunk;
}

if (shouldUseDispatchThunk) {
llvm::Constant *fnPtr = IGM.getAddrOfDispatchThunk(method, NotForDefinition);
void IRGenSILFunction::visitClassMethodInst(swift::ClassMethodInst *i) {
assert(!i->getMember().isForeign);

Explosion base = getLoweredExplosion(i->getOperand());
llvm::Value *baseValue = base.claimNext();

SILDeclRef method = i->getMember().getOverriddenVTableEntry();
PrettyStackTraceSILDeclRef entry("lowering class method call to", method);

auto methodType = i->getType().castTo<SILFunctionType>();
if (shouldUseDispatchThunk(method)) {
llvm::Constant *fnPtr =
IGM.getAddrOfDispatchThunk(method, NotForDefinition);

if (methodType->isAsync()) {
auto *fnPtrType = fnPtr->getType();
Expand Down