Skip to content

Commit c56ae1e

Browse files
authored
Merge pull request #33851 from freddi-kit/fix/may-trap-condition
[sil-opt] Fix covering all-case of trapping instruction of SILInstruction::mayTrap
2 parents e6f7b9d + 2676839 commit c56ae1e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/SIL/IR/SILInstruction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,7 @@ bool SILInstruction::mayTrap() const {
12661266
case SILInstructionKind::CondFailInst:
12671267
case SILInstructionKind::UnconditionalCheckedCastInst:
12681268
case SILInstructionKind::UnconditionalCheckedCastAddrInst:
1269+
case SILInstructionKind::UnconditionalCheckedCastValueInst:
12691270
return true;
12701271
default:
12711272
return false;

test/SILOptimizer/side-effect.sil

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,23 @@ bb0(%0 : $Builtin.NativeObject):
210210
return %r : $()
211211
}
212212

213+
// CHECK-LABEL: sil @checkedaddr
214+
// CHECK: <func=rw+-,param0=,param1=;alloc;trap;readrc>
215+
sil @checkedaddr : $@convention(thin) (Builtin.NativeObject, X) -> () {
216+
bb0(%0 : $Builtin.NativeObject, %1 : $X):
217+
unconditional_checked_cast_addr Builtin.NativeObject in %0 : $Builtin.NativeObject to X in %1 : $X
218+
%r = tuple ()
219+
return %r : $()
220+
}
221+
222+
// CHECK-LABEL: sil @checkedcastvalue
223+
// CHECK: <func=r,param0=;trap>
224+
sil @checkedcastvalue : $@convention(thin) (Builtin.NativeObject) -> () {
225+
bb0(%0 : $Builtin.NativeObject):
226+
%1 = unconditional_checked_cast_value Builtin.NativeObject in %0 : $Builtin.NativeObject to X
227+
%r = tuple ()
228+
return %r : $()
229+
}
213230

214231
sil_global public @sil_global1 : $Int32
215232

0 commit comments

Comments
 (0)