SILGen: Simplify prepareEpilog() utility method

This commit is contained in:
Slava Pestov
2020-02-18 16:23:34 -05:00
parent e4a4dfe5c4
commit 3547122997
6 changed files with 16 additions and 22 deletions

View File

@@ -487,8 +487,7 @@ void SILGenFunction::emitFunction(FuncDecl *fd) {
auto captureInfo = SGM.M.Types.getLoweredLocalCaptures(SILDeclRef(fd));
emitProlog(captureInfo, fd->getParameters(), fd->getImplicitSelfDecl(), fd,
fd->getResultInterfaceType(), fd->hasThrows(), fd->getThrowsLoc());
Type resultTy = fd->mapTypeIntoContext(fd->getResultInterfaceType());
prepareEpilog(resultTy, fd->hasThrows(), CleanupLocation(fd));
prepareEpilog(true, fd->hasThrows(), CleanupLocation(fd));
emitProfilerIncrement(fd->getBody());
emitStmt(fd->getBody());
@@ -506,8 +505,7 @@ void SILGenFunction::emitClosure(AbstractClosureExpr *ace) {
SILDeclRef(ace));
emitProlog(captureInfo, ace->getParameters(), /*selfParam=*/nullptr,
ace, resultIfaceTy, ace->isBodyThrowing(), ace->getLoc());
prepareEpilog(ace->getResultType(), ace->isBodyThrowing(),
CleanupLocation(ace));
prepareEpilog(true, ace->isBodyThrowing(), CleanupLocation(ace));
emitProfilerIncrement(ace);
if (auto *ce = dyn_cast<ClosureExpr>(ace)) {
emitStmt(ce->getBody());
@@ -743,7 +741,7 @@ void SILGenFunction::emitGeneratorFunction(SILDeclRef function, Expr *value,
dc, interfaceType, /*throws=*/false, SourceLoc());
if (EmitProfilerIncrement)
emitProfilerIncrement(value);
prepareEpilog(value->getType(), false, CleanupLocation::get(Loc));
prepareEpilog(true, false, CleanupLocation::get(Loc));
{
llvm::Optional<SILGenFunction::OpaqueValueRAII> opaqueValue;
@@ -776,7 +774,6 @@ void SILGenFunction::emitGeneratorFunction(SILDeclRef function, VarDecl *var) {
auto decl = function.getAbstractFunctionDecl();
auto *dc = decl->getInnermostDeclContext();
auto interfaceType = var->getValueInterfaceType();
auto varType = var->getType();
// If this is the backing storage for a property with an attached
// wrapper that was initialized with '=', the stored property initializer
@@ -784,13 +781,12 @@ void SILGenFunction::emitGeneratorFunction(SILDeclRef function, VarDecl *var) {
if (auto originalProperty = var->getOriginalWrappedProperty()) {
if (originalProperty->isPropertyMemberwiseInitializedWithWrappedType()) {
interfaceType = originalProperty->getValueInterfaceType();
varType = originalProperty->getType();
}
}
emitProlog(/*paramList*/ nullptr, /*selfParam*/ nullptr, interfaceType, dc,
/*throws=*/false, SourceLoc());
prepareEpilog(varType, false, CleanupLocation::get(loc));
prepareEpilog(true, false, CleanupLocation::get(loc));
auto pbd = var->getParentPatternBinding();
const auto i = pbd->getPatternEntryIndexForVarDecl(var);