Skip to content

Commit cac313d

Browse files
committed
Disable cast optimization for address-only types.
The code gen assumes the type is loadable. Disable for now to avoid bugs.
1 parent 5111a42 commit cac313d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ class SILBuilder {
424424
}
425425

426426
LoadInst *createLoad(SILLocation Loc, SILValue LV) {
427+
assert(LV->getType().isLoadable(F.getModule()));
427428
return insert(new (F.getModule())
428429
LoadInst(getSILDebugLocation(Loc), LV));
429430
}

lib/SILOptimizer/Utils/Local.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,11 @@ optimizeBridgedObjCToSwiftCast(SILInstruction *Inst,
14261426
assert(Src->getType().isAddress() && "Source should have an address type");
14271427
assert(Dest->getType().isAddress() && "Source should have an address type");
14281428

1429+
if (!Src->getType().isLoadable(M) || !Dest->getType().isLoadable(M)) {
1430+
// TODO: Handle address only types.
1431+
return nullptr;
1432+
}
1433+
14291434
if (SILBridgedTy != Src->getType()) {
14301435
// Check if we can simplify a cast into:
14311436
// - ObjCTy to _ObjectiveCBridgeable._ObjectiveCType.
@@ -1603,6 +1608,11 @@ optimizeBridgedSwiftToObjCCast(SILInstruction *Inst,
16031608

16041609
auto &M = Inst->getModule();
16051610
auto Loc = Inst->getLoc();
1611+
1612+
if (!Src->getType().isLoadable(M) || !Dest->getType().isLoadable(M)) {
1613+
// TODO: Handle address-only types.
1614+
return nullptr;
1615+
}
16061616

16071617
// Find the _BridgedToObjectiveC protocol.
16081618
auto BridgedProto =

0 commit comments

Comments
 (0)