Don't hardcode the function representation of builtin "once". Make emitLazyGlobalInitializer retrieve the convention from getBuiltinValueDecl.

This commit is contained in:
Kuba Mracek
2018-01-02 23:13:08 -08:00
parent 17fa484f04
commit 0b7bb605cb
8 changed files with 31 additions and 29 deletions

View File

@@ -975,10 +975,12 @@ SILFunction *SILGenModule::emitLazyGlobalInitializer(StringRef funcName,
PatternBindingDecl *binding,
unsigned pbdEntry) {
ASTContext &C = M.getASTContext();
Type initType = FunctionType::get(
TupleType::getEmpty(C), TupleType::getEmpty(C),
FunctionType::ExtInfo()
.withRepresentation(FunctionType::Representation::Thin));
auto *onceBuiltin =
cast<FuncDecl>(getBuiltinValueDecl(C, C.getIdentifier("once")));
auto blockParam = onceBuiltin->getParameterLists()[0]->get(1);
auto *type = blockParam->getType()->castTo<FunctionType>();
Type initType = FunctionType::get(TupleType::getEmpty(C),
TupleType::getEmpty(C), type->getExtInfo());
auto initSILType = getLoweredType(initType).castTo<SILFunctionType>();
auto *f =