SILGen: Apply function_conversion peephole to CaptureListExprs.

Don't let a capture list suppress the reabstraction peephole when a closure
literal appears in a context with a function conversion.
This commit is contained in:
Joe Groff
2022-09-21 15:11:59 -07:00
parent c6b6787f74
commit d06f7b15d7
3 changed files with 46 additions and 1 deletions

View File

@@ -82,6 +82,7 @@
//
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "silgen-poly"
#include "ExecutorBreadcrumb.h"
#include "Initialization.h"
#include "LValue.h"
@@ -3055,6 +3056,24 @@ static ManagedValue createThunk(SILGenFunction &SGF,
auto substSourceType = fn.getType().castTo<SILFunctionType>();
auto substExpectedType = expectedTL.getLoweredType().castTo<SILFunctionType>();
LLVM_DEBUG(llvm::dbgs() << "=== Generating reabstraction thunk from:\n";
substSourceType.dump(llvm::dbgs());
llvm::dbgs() << "\n to:\n";
substExpectedType.dump(llvm::dbgs());
llvm::dbgs() << "\n for source location:\n";
if (auto d = loc.getAsASTNode<Decl>()) {
d->dump(llvm::dbgs());
} else if (auto e = loc.getAsASTNode<Expr>()) {
e->dump(llvm::dbgs());
} else if (auto s = loc.getAsASTNode<Stmt>()) {
s->dump(llvm::dbgs());
} else if (auto p = loc.getAsASTNode<Pattern>()) {
p->dump(llvm::dbgs());
} else {
loc.dump();
}
llvm::dbgs() << "\n");
// Apply substitutions in the source and destination types, since the thunk
// doesn't change because of different function representations.
CanSILFunctionType sourceType;