Skip to content

Commit ec9afec

Browse files
authored
Merge pull request #31096 from eeckstein/fix-casts
SIL: support type dependent operands in all cast instructions.
2 parents 85fdc7a + 351d9c5 commit ec9afec

File tree

4 files changed

+301
-185
lines changed

4 files changed

+301
-185
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,9 +1031,9 @@ class SILBuilder {
10311031
createUncheckedRefCastAddr(SILLocation Loc,
10321032
SILValue src, CanType sourceFormalType,
10331033
SILValue dest, CanType targetFormalType) {
1034-
return insert(new (getModule()) UncheckedRefCastAddrInst(
1034+
return insert(UncheckedRefCastAddrInst::create(
10351035
getSILDebugLocation(Loc), src, sourceFormalType,
1036-
dest, targetFormalType));
1036+
dest, targetFormalType, getFunction(), C.OpenedArchetypes));
10371037
}
10381038

10391039
UncheckedAddrCastInst *createUncheckedAddrCast(SILLocation Loc, SILValue Op,
@@ -1152,9 +1152,9 @@ class SILBuilder {
11521152
createUnconditionalCheckedCastAddr(SILLocation Loc,
11531153
SILValue src, CanType sourceFormalType,
11541154
SILValue dest, CanType targetFormalType) {
1155-
return insert(new (getModule()) UnconditionalCheckedCastAddrInst(
1155+
return insert(UnconditionalCheckedCastAddrInst::create(
11561156
getSILDebugLocation(Loc), src, sourceFormalType,
1157-
dest, targetFormalType));
1157+
dest, targetFormalType, getFunction(), C.OpenedArchetypes));
11581158
}
11591159

11601160
UnconditionalCheckedCastValueInst *
@@ -1989,9 +1989,10 @@ class SILBuilder {
19891989
SILBasicBlock *failureBB,
19901990
ProfileCounter Target1Count = ProfileCounter(),
19911991
ProfileCounter Target2Count = ProfileCounter()) {
1992-
return insertTerminator(new (getModule()) CheckedCastAddrBranchInst(
1992+
return insertTerminator(CheckedCastAddrBranchInst::create(
19931993
getSILDebugLocation(Loc), consumption, src, sourceFormalType, dest,
1994-
targetFormalType, successBB, failureBB, Target1Count, Target2Count));
1994+
targetFormalType, successBB, failureBB, Target1Count, Target2Count,
1995+
getFunction(), C.OpenedArchetypes));
19951996
}
19961997

19971998
//===--------------------------------------------------------------------===//

0 commit comments

Comments
 (0)