SIL: Refactor TypeConverter to not require a SILModule

This mostly requires changing various entry points to pass around a
TypeConverter instead of a SILModule. I've left behind entry points
that take a SILModule for a few methods like SILType::subst() to
avoid creating even more churn.
This commit is contained in:
Slava Pestov
2019-08-27 18:41:28 -04:00
parent f487f7b012
commit d434188157
31 changed files with 355 additions and 304 deletions

View File

@@ -436,7 +436,8 @@ static bool rewriteAllocBoxAsAllocStack(AllocBoxInst *ABI) {
assert(ABI->getBoxType()->getLayout()->getFields().size() == 1
&& "rewriting multi-field box not implemented");
auto *ASI = Builder.createAllocStack(
ABI->getLoc(), ABI->getBoxType()->getFieldType(ABI->getModule(), 0),
ABI->getLoc(),
getSILBoxFieldType(ABI->getBoxType(), ABI->getModule().Types, 0),
ABI->getVarInfo(), ABI->hasDynamicLifetime());
// Transfer a mark_uninitialized if we have one.
@@ -453,7 +454,8 @@ static bool rewriteAllocBoxAsAllocStack(AllocBoxInst *ABI) {
assert(ABI->getBoxType()->getLayout()->getFields().size() == 1
&& "promoting multi-field box not implemented");
auto &Lowering = ABI->getFunction()
->getTypeLowering(ABI->getBoxType()->getFieldType(ABI->getModule(), 0));
->getTypeLowering(
getSILBoxFieldType(ABI->getBoxType(), ABI->getModule().Types, 0));
auto Loc = CleanupLocation::get(ABI->getLoc());
for (auto LastRelease : FinalReleases) {
@@ -581,9 +583,10 @@ initCloned(SILOptFunctionBuilder &FuncBuilder, SILFunction *Orig,
&& "promoting compound box not implemented");
SILType paramTy;
{
Lowering::GenericContextScope scope(Orig->getModule().Types,
auto &TC = Orig->getModule().Types;
Lowering::GenericContextScope scope(TC,
OrigFTI->getGenericSignature());
paramTy = boxTy->getFieldType(Orig->getModule(), 0);
paramTy = getSILBoxFieldType(boxTy, TC, 0);
}
auto promotedParam = SILParameterInfo(paramTy.getASTType(),
ParameterConvention::Indirect_InoutAliasable);
@@ -647,7 +650,7 @@ PromotedParamCloner::populateCloned() {
auto boxTy = (*I)->getType().castTo<SILBoxType>();
assert(boxTy->getLayout()->getFields().size() == 1
&& "promoting multi-field boxes not implemented yet");
auto promotedTy = boxTy->getFieldType(Cloned->getModule(), 0);
auto promotedTy = getSILBoxFieldType(boxTy, Cloned->getModule().Types, 0);
auto *promotedArg =
ClonedEntryBB->createFunctionArgument(promotedTy, (*I)->getDecl());
OrigPromotedParameters.insert(*I);