mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
DynamicCasts: Emit a direct copy if soure and target SIL types match
unconditional_checked_cast_addr ImplicitlyUnwrappedOptional<AnyObject> in %136 : *Optional<AnyObject> to *Optional<AnyObject> in %135 rdar://35987160
This commit is contained in:
@@ -737,6 +737,8 @@ namespace {
|
||||
|
||||
bool isAddress() const { return Value->getType().isAddress(); }
|
||||
|
||||
SILType getSILType() const { return Value->getType(); }
|
||||
|
||||
Source() = default;
|
||||
Source(SILValue value, CanType formalType)
|
||||
: Value(value), FormalType(formalType) {}
|
||||
@@ -758,6 +760,12 @@ namespace {
|
||||
assert(!value->getType().isAddress());
|
||||
return { value, FormalType };
|
||||
}
|
||||
SILType getSILType() const {
|
||||
if (isAddress())
|
||||
return Address->getType();
|
||||
else
|
||||
return LoweredType;
|
||||
}
|
||||
|
||||
Target() = default;
|
||||
Target(SILValue address, CanType formalType)
|
||||
@@ -813,7 +821,8 @@ namespace {
|
||||
}
|
||||
|
||||
Source emitSameType(Source source, Target target) {
|
||||
assert(source.FormalType == target.FormalType);
|
||||
assert(source.FormalType == target.FormalType ||
|
||||
source.getSILType() == target.getSILType());
|
||||
|
||||
auto &srcTL = getTypeLowering(source.Value->getType());
|
||||
|
||||
@@ -845,7 +854,8 @@ namespace {
|
||||
}
|
||||
|
||||
Source emit(Source source, Target target) {
|
||||
if (source.FormalType == target.FormalType)
|
||||
if (source.FormalType == target.FormalType ||
|
||||
source.getSILType() == target.getSILType())
|
||||
return emitSameType(source, target);
|
||||
|
||||
// Handle subtype conversions involving optionals.
|
||||
|
||||
Reference in New Issue
Block a user