mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[cast-opt] Eliminate some unneeded type checks in favor of just asserting the instructions we handle.
This code today only handles the following two instructions: 1. checked_cast_addr_br 2. unconditional_checked_cast_addr We were asserting that the source/dest of these values were addresses... but they are obviously are!
This commit is contained in:
@@ -72,6 +72,12 @@ getObjCToSwiftBridgingFunction(SILOptFunctionBuilder &funcBuilder,
|
||||
/// _ObjectiveCBridgeable.
|
||||
SILInstruction *
|
||||
CastOptimizer::optimizeBridgedObjCToSwiftCast(SILDynamicCastInst dynamicCast) {
|
||||
auto kind = dynamicCast.getKind();
|
||||
(void)kind;
|
||||
assert(((kind == SILDynamicCastKind::CheckedCastAddrBranchInst) ||
|
||||
(kind == SILDynamicCastKind::UnconditionalCheckedCastAddrInst)) &&
|
||||
"Unsupported dynamic cast kind");
|
||||
|
||||
CanType target = dynamicCast.getTargetType();
|
||||
auto &mod = dynamicCast.getModule();
|
||||
|
||||
@@ -108,9 +114,6 @@ CastOptimizer::optimizeBridgedObjCToSwiftCast(SILDynamicCastInst dynamicCast) {
|
||||
SILValue SrcOp;
|
||||
SILInstruction *NewI = nullptr;
|
||||
|
||||
assert(Src->getType().isAddress() && "Source should have an address type");
|
||||
assert(Dest->getType().isAddress() && "Source should have an address type");
|
||||
|
||||
// If this is a conditional cast:
|
||||
// We need a new fail BB in order to add a dealloc_stack to it
|
||||
SILBasicBlock *ConvFailBB = nullptr;
|
||||
@@ -121,10 +124,6 @@ CastOptimizer::optimizeBridgedObjCToSwiftCast(SILDynamicCastInst dynamicCast) {
|
||||
Builder.setInsertionPoint(CurrInsPoint);
|
||||
}
|
||||
|
||||
// We know this is always true since SILBridgedTy is an object and Src is an
|
||||
// address.
|
||||
assert(SILBridgedTy != Src->getType());
|
||||
|
||||
// Check if we can simplify a cast into:
|
||||
// - ObjCTy to _ObjectiveCBridgeable._ObjectiveCType.
|
||||
// - then convert _ObjectiveCBridgeable._ObjectiveCType to
|
||||
|
||||
Reference in New Issue
Block a user