Skip to content

[SILGen] NFC: Remove unused emitApplyMethod #61478

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 1 commit into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
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
72 changes: 0 additions & 72 deletions lib/SILGen/SILGenApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5265,78 +5265,6 @@ RValue SILGenFunction::emitApplyAllocatingInitializer(SILLocation loc,
return result;
}

/// Emit an application of the given method.
RValue SILGenFunction::emitApplyMethod(SILLocation loc, ConcreteDeclRef declRef,
ArgumentSource &&self,
PreparedArguments &&args, SGFContext C) {
auto *call = cast<AbstractFunctionDecl>(declRef.getDecl());

// Form the reference to the method.
auto callRef = SILDeclRef(call, SILDeclRef::Kind::Func)
.asForeign(requiresForeignEntryPoint(declRef.getDecl()));

if (auto distributedThunk = call->getDistributedThunk()) {
callRef = SILDeclRef(distributedThunk).asDistributed();
} else if (call->isBackDeployed()) {
callRef =
callRef.asBackDeploymentKind(SILDeclRef::BackDeploymentKind::Thunk);
}

auto declRefConstant = getConstantInfo(getTypeExpansionContext(), callRef);
auto subs = declRef.getSubstitutions();
bool throws = false;
bool markedAsRethrows = call->getAttrs().hasAttribute<swift::RethrowsAttr>();
PolymorphicEffectKind rethrowingKind =
call->getPolymorphicEffectKind(EffectKind::Throws);
if (rethrowingKind == PolymorphicEffectKind::ByConformance) {
for (auto conformanceRef : subs.getConformances()) {
if (conformanceRef.hasEffect(EffectKind::Throws)) {
throws = true;
break;
}
}
} else if (markedAsRethrows &&
rethrowingKind == PolymorphicEffectKind::Always) {
throws = true;
}

// Scope any further writeback just within this operation.
FormalEvaluationScope writebackScope(*this);

// Form the metatype argument.
ManagedValue selfMetaVal;
SILType selfMetaTy;
{
// Determine the self metatype type.
CanSILFunctionType substFnType =
declRefConstant.SILFnType->substGenericArgs(SGM.M, subs,
getTypeExpansionContext());
SILType selfParamMetaTy =
getSILType(substFnType->getSelfParameter(), substFnType);
selfMetaTy = selfParamMetaTy;
}

// Form the callee.
Optional<Callee> callee;
if (isa<ProtocolDecl>(call->getDeclContext())) {
callee.emplace(Callee::forWitnessMethod(*this, selfMetaTy.getASTType(),
callRef, subs, loc));
} else if (getMethodDispatch(call) == MethodDispatch::Class) {
callee.emplace(Callee::forClassMethod(*this, callRef, subs, loc));
} else {
callee.emplace(Callee::forDirect(*this, callRef, subs, loc));
}

auto substFormalType = callee->getSubstFormalType();

// Form the call emission.
CallEmission emission(*this, std::move(*callee), std::move(writebackScope));
emission.addSelfParam(loc, std::move(self), substFormalType.getParams()[0]);
emission.addCallSite(loc, std::move(args), !throws);

return emission.apply(C);
}

RValue SILGenFunction::emitApplyOfPropertyWrapperBackingInitializer(
SILLocation loc,
VarDecl *var,
Expand Down
4 changes: 0 additions & 4 deletions lib/SILGen/SILGenFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -1751,10 +1751,6 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
PreparedArguments &&args, Type overriddenSelfType,
SGFContext ctx);

RValue emitApplyMethod(SILLocation loc, ConcreteDeclRef declRef,
ArgumentSource &&self, PreparedArguments &&args,
SGFContext C);

CleanupHandle emitBeginApply(SILLocation loc, ManagedValue fn,
SubstitutionMap subs, ArrayRef<ManagedValue> args,
CanSILFunctionType substFnType,
Expand Down