[SE-0155] Default Arguments in Enum Cases

The bulk of the changes are to SILGenApply.  As we must now evaluate the
payload ArgumentSource to an RValue, we follow the example of subscripts
and lie to the argument emitter.  This evaluates arguments at +1 which
can lead to slightly worse codegen at -Onone.
This commit is contained in:
Robert Widmann
2018-10-27 01:44:59 -04:00
parent 498b72270b
commit 944d8d06d7
15 changed files with 222 additions and 69 deletions

View File

@@ -467,8 +467,14 @@ IsSerialized_t SILDeclRef::isSerialized() const {
// Default argument generators are serialized if the function was
// type-checked in Swift 4 mode.
if (isDefaultArgGenerator()) {
auto *afd = cast<AbstractFunctionDecl>(d);
switch (afd->getDefaultArgumentResilienceExpansion()) {
ResilienceExpansion expansion;
if (auto *EED = dyn_cast<EnumElementDecl>(d)) {
expansion = EED->getDefaultArgumentResilienceExpansion();
} else {
expansion = cast<AbstractFunctionDecl>(d)
->getDefaultArgumentResilienceExpansion();
}
switch (expansion) {
case ResilienceExpansion::Minimal:
return IsSerialized;
case ResilienceExpansion::Maximal:
@@ -770,7 +776,7 @@ std::string SILDeclRef::mangle(ManglingKind MKind) const {
case SILDeclRef::Kind::DefaultArgGenerator:
assert(!isCurried);
return mangler.mangleDefaultArgumentEntity(
cast<AbstractFunctionDecl>(getDecl()),
cast<DeclContext>(getDecl()),
defaultArgIndex,
SKind);