Skip to content

Commit 0f40089

Browse files
committed
[SILGen] Move closure emission to emitFunctionDefinition
1 parent cc8344a commit 0f40089

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,14 @@ void SILGenModule::visitFuncDecl(FuncDecl *fd) { emitFunction(fd); }
679679
void SILGenModule::emitFunctionDefinition(SILDeclRef constant, SILFunction *f) {
680680
switch (constant.kind) {
681681
case SILDeclRef::Kind::Func: {
682+
if (auto *ce = constant.getAbstractClosureExpr()) {
683+
preEmitFunction(constant, f, ce);
684+
PrettyStackTraceSILFunction X("silgen closureexpr", f);
685+
SILGenFunction(*this, *f, ce).emitClosure(ce);
686+
postEmitFunction(constant, f);
687+
break;
688+
}
689+
682690
auto *fd = cast<FuncDecl>(constant.getDecl());
683691

684692
preEmitFunction(constant, f, fd);
@@ -1207,10 +1215,8 @@ SILFunction *SILGenModule::emitClosure(AbstractClosureExpr *ce) {
12071215
// initializer of the containing type.
12081216
if (!f->isExternalDeclaration())
12091217
return f;
1210-
preEmitFunction(constant, f, ce);
1211-
PrettyStackTraceSILFunction X("silgen closureexpr", f);
1212-
SILGenFunction(*this, *f, ce).emitClosure(ce);
1213-
postEmitFunction(constant, f);
1218+
1219+
emitFunctionDefinition(constant, f);
12141220
return f;
12151221
}
12161222

0 commit comments

Comments
 (0)