File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ bool ConditionForwarding::tryOptimize(SwitchEnumInst *SEI) {
237237 if (getFunction ()->hasOwnership ()) {
238238 // TODO: Currently disabled because this case may need lifetime extension
239239 // Disabling this conservatively for now.
240- assert (Condition->getNumOperands () == 1 );
240+ assert (Condition->getNumRealOperands () == 1 );
241241 BorrowedValue conditionOp (Condition->getOperand (0 ));
242242 if (conditionOp && conditionOp.isLocalScope ()) {
243243 return false ;
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ class C {
1414 init()
1515}
1616
17+ final class D: C {}
18+
1719sil [ossa] @callee : $@convention(thin) () -> ()
1820sil [ossa] @use_enum : $@convention(thin) (E) -> ()
1921sil [ossa] @use_int : $@convention(thin) (Builtin.Int64) -> ()
@@ -388,3 +390,32 @@ bb6:
388390 return %r : $()
389391}
390392
393+ // CHECK-LABEL: sil [ossa] @cast_with_type_dependent_operand :
394+ // CHECK-NOT: switch_enum
395+ // CHECK-LABEL: } // end sil function 'cast_with_type_dependent_operand'
396+ sil [ossa] @cast_with_type_dependent_operand : $@convention(method) (@guaranteed C, @guaranteed D) -> () {
397+ bb0(%0 : @guaranteed $C, %1 : @guaranteed $D):
398+ checked_cast_br C in %0 to @dynamic_self D, bb1, bb2
399+
400+ bb1(%3 : @guaranteed $D):
401+ %4 = enum $Optional<D>, #Optional.some!enumelt, %3
402+ br bb3(%4)
403+
404+ bb2(%6 : @guaranteed $C):
405+ %7 = enum $Optional<D>, #Optional.none!enumelt
406+ br bb3(%7)
407+
408+ bb3(%9 : @guaranteed $Optional<D>):
409+ %10 = borrowed %9 from (%0)
410+ switch_enum %10, case #Optional.some!enumelt: bb4, case #Optional.none!enumelt: bb5
411+
412+ bb4(%12 : @guaranteed $D):
413+ br bb6
414+
415+ bb5:
416+ br bb6
417+
418+ bb6:
419+ %15 = tuple ()
420+ return %15
421+ }
You can’t perform that action at this time.
0 commit comments