SIL: Use the best resilience expansion when lowering types

This is a large patch; I couldn't split it up further while still
keeping things working. There are four things being changed at
once here:

- Places that call SILType::isAddressOnly()/isLoadable() now call
  the SILFunction overload and not the SILModule one.

- SILFunction's overloads of getTypeLowering() and getLoweredType()
  now pass the function's resilience expansion down, instead of
  hardcoding ResilienceExpansion::Minimal.

- Various other places with '// FIXME: Expansion' now use a better
  resilience expansion.

- A few tests were updated to reflect SILGen's improved code
  generation, and some new tests are added to cover more code paths
  that previously were uncovered and only manifested themselves as
  standard library build failures while I was working on this change.
This commit is contained in:
Slava Pestov
2019-03-13 02:06:27 -04:00
parent fb8bd3a056
commit 16d5716e71
46 changed files with 548 additions and 214 deletions

View File

@@ -4669,7 +4669,7 @@ ManagedValue SILGenFunction::emitInjectEnum(SILLocation loc,
SGFContext C) {
// Easy case -- no payload
if (!payload) {
if (enumTy.isLoadable(SGM.M) || !silConv.useLoweredAddresses()) {
if (enumTy.isLoadable(F) || !silConv.useLoweredAddresses()) {
return emitManagedRValueWithCleanup(
B.createEnum(loc, SILValue(), element, enumTy.getObjectType()));
}
@@ -4714,7 +4714,7 @@ ManagedValue SILGenFunction::emitInjectEnum(SILLocation loc,
}
// Loadable with payload
if (enumTy.isLoadable(SGM.M) || !silConv.useLoweredAddresses()) {
if (enumTy.isLoadable(F) || !silConv.useLoweredAddresses()) {
if (!payloadMV) {
// If the payload was indirect, we already evaluated it and
// have a single value. Otherwise, evaluate the payload.
@@ -5304,7 +5304,7 @@ ArgumentSource AccessorBaseArgPreparer::prepareAccessorAddressBaseArg() {
// If the base is currently an address, we may have to copy it.
if (shouldLoadBaseAddress()) {
if (selfParam.isConsumed() ||
base.getType().isAddressOnly(SGF.getModule())) {
base.getType().isAddressOnly(SGF.F)) {
// The load can only be a take if the base is a +1 rvalue.
auto shouldTake = IsTake_t(base.hasCleanup());