[Async CC] Put direct returns after indirect returns.

For callers who do not know the actual type of the called function, e.g.
when the called function is the result of a partial apply, the offset to
the direct returns would otherwise not be known.
This commit is contained in:
Nate Chandler
2020-10-14 13:58:03 -07:00
parent 6fce6d9363
commit 97202faee5
2 changed files with 23 additions and 18 deletions

View File

@@ -121,6 +121,17 @@ AsyncContextLayout irgen::getAsyncContextLayout(
indirectReturnInfos.push_back(indirectResult);
}
// ResultTypes directResults...;
auto directResults = fnConv.getDirectSILResults();
for (auto result : directResults) {
auto ty =
fnConv.getSILType(result, IGF.IGM.getMaximalTypeExpansionContext());
auto &ti = IGF.getTypeInfoForLowered(ty.getASTType());
valTypes.push_back(ty);
typeInfos.push_back(&ti);
directReturnInfos.push_back(result);
}
// SelfType self?;
bool hasLocalContextParameter = hasSelfContextParameter(substitutedType);
bool canHaveValidError = substitutedType->hasErrorResult();
@@ -203,17 +214,6 @@ AsyncContextLayout irgen::getAsyncContextLayout(
trailingWitnessInfo = AsyncContextLayout::TrailingWitnessInfo();
}
// ResultTypes directResults...;
auto directResults = fnConv.getDirectSILResults();
for (auto result : directResults) {
auto ty =
fnConv.getSILType(result, IGF.IGM.getMaximalTypeExpansionContext());
auto &ti = IGF.getTypeInfoForLowered(ty.getASTType());
valTypes.push_back(ty);
typeInfos.push_back(&ti);
directReturnInfos.push_back(result);
}
return AsyncContextLayout(
IGF.IGM, LayoutStrategy::Optimal, valTypes, typeInfos, IGF, originalType,
substitutedType, substitutionMap, std::move(bindings),