IRGen: Generalize the nullable optimization for single-payload enums.

Augment the `isSingleRetainablePointer` check that allows IRGen to avoid adding branching around retain/release operations on enums that use the null pointer extra inhabitant with a more general "can value witness extra inhabitants" method on TypeInfo, which says whether a type's retain/release operations are safe to invoke on some or all of its extra inhabitants. This lets us generalize the optimization to include things like `String?` or `ClassProtocol?` which are common types with a nullable pointer in them.
This commit is contained in:
Joe Groff
2018-03-19 12:01:50 -07:00
parent 869e579477
commit 950ee3b0de
10 changed files with 252 additions and 7 deletions

View File

@@ -219,7 +219,7 @@ namespace {
return false;
return fields[0].getTypeInfo().isSingleRetainablePointer(expansion, rc);
}
void verify(IRGenTypeVerifierFunction &IGF,
llvm::Value *metadata,
SILType structType) const override {