mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user