Skip to content

Commit 1e7990c

Browse files
committed
[sil-combine] Enable cond_fail elimination for ownership.
1 parent 5572d04 commit 1e7990c

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,9 +1066,6 @@ SILInstruction *SILCombiner::visitRetainValueInst(RetainValueInst *RVI) {
10661066
}
10671067

10681068
SILInstruction *SILCombiner::visitCondFailInst(CondFailInst *CFI) {
1069-
if (CFI->getFunction()->hasOwnership())
1070-
return nullptr;
1071-
10721069
// Remove runtime asserts such as overflow checks and bounds checks.
10731070
if (RemoveCondFails)
10741071
return eraseInstFromFunction(*CFI);

test/SILOptimizer/sil_combine_ossa.sil

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -528,11 +528,12 @@ bb0(%0 : @owned $HeapBufferStorage<T_0_0, T_0_1>):
528528
return %3 : $HeapBufferStorage<T_0_0, T_0_1>
529529
}
530530

531-
// CHECK-LABEL: sil [ossa] @cond_fail_applied_to_zero_removal
532-
// XHECK: bb0
533-
// XHECK-NEXT: cond_fail
534-
// XHECK-NEXT: tuple ()
535-
// XHECK-NEXT: return
531+
// CHECK-LABEL: sil [ossa] @cond_fail_applied_to_zero_removal :
532+
// CHECK: bb0
533+
// CHECK-NEXT: cond_fail
534+
// CHECK-NEXT: tuple ()
535+
// CHECK-NEXT: return
536+
// CHECK: } // end sil function 'cond_fail_applied_to_zero_removal'
536537
sil [ossa] @cond_fail_applied_to_zero_removal : $@convention(thin) (Builtin.Int1) -> () {
537538
bb0(%0 : $Builtin.Int1):
538539
cond_fail %0 : $Builtin.Int1
@@ -2051,10 +2052,11 @@ bb0(%0 : $Int):
20512052
return %8 : $()
20522053
}
20532054

2054-
// CHECK-LABEL: @remove_pointer_compare_to_zero_NE
2055-
// XHECK-NOT: apply
2056-
// XHECK: cond_fail
2057-
// XHECK: unreachable
2055+
// CHECK-LABEL: @remove_pointer_compare_to_zero_NE :
2056+
// CHECK-NOT: apply
2057+
// CHECK: cond_fail
2058+
// CHECK: unreachable
2059+
// CHECK: } // end sil function 'remove_pointer_compare_to_zero_NE'
20582060
sil [ossa] @remove_pointer_compare_to_zero_NE : $@convention(thin) (Int) -> () {
20592061
bb0(%0 : $Int):
20602062
%1 = string_literal utf8 "ss"
@@ -2701,11 +2703,11 @@ bb0(%0 : $Builtin.RawPointer, %1 : $*Builtin.UnsafeValueBuffer, %2 : $*GenContai
27012703
}
27022704

27032705

2704-
// CHECK-LABEL: sil [ossa] @remove_dead_code_after_cond_fail
2705-
// XHECK: [[Ref:%.*]] = integer_literal $Builtin.Int1, -1
2706-
// XHECK-NEXT: cond_fail [[Ref]]
2707-
// XHECK-NEXT: unreachable
2708-
2706+
// CHECK-LABEL: sil [ossa] @remove_dead_code_after_cond_fail :
2707+
// CHECK: [[Ref:%.*]] = integer_literal $Builtin.Int1, -1
2708+
// CHECK-NEXT: cond_fail [[Ref]]
2709+
// CHECK-NEXT: unreachable
2710+
// CHECK: } // end sil function 'remove_dead_code_after_cond_fail'
27092711
sil [ossa] @remove_dead_code_after_cond_fail : $@convention(thin) () -> (Int32) {
27102712
bb0:
27112713
%0 = integer_literal $Builtin.Int32, -2
@@ -2717,12 +2719,12 @@ bb0:
27172719

27182720

27192721
// CHECK-LABEL: sil [ossa] @dont_remove_code_after_cond_fail
2720-
// XHECK: bb0([[Cond:%.*]] : $Builtin.Int1):
2721-
// XHECK-NEXT: [[Ref:%.*]] = integer_literal $Builtin.Int32, -2
2722-
// XHECK-NEXT: cond_fail [[Cond]]
2723-
// XHECK-NEXT: [[Ret:%.*]] = struct $Int32 ([[Ref]] : $Builtin.Int32)
2724-
// XHECK-NEXT: return [[Ret]]
2725-
2722+
// CHECK: bb0([[Cond:%.*]] : $Builtin.Int1):
2723+
// CHECK-NEXT: [[Ref:%.*]] = integer_literal $Builtin.Int32, -2
2724+
// CHECK-NEXT: cond_fail [[Cond]]
2725+
// CHECK-NEXT: [[Ret:%.*]] = struct $Int32 ([[Ref]] : $Builtin.Int32)
2726+
// CHECK-NEXT: return [[Ret]]
2727+
// CHECK: } // end sil function 'dont_remove_code_after_cond_fail'
27262728
sil [ossa] @dont_remove_code_after_cond_fail : $@convention(thin) (Builtin.Int1) -> (Int32) {
27272729
bb0(%0 : $Builtin.Int1):
27282730
%1 = integer_literal $Builtin.Int32, -2

0 commit comments

Comments
 (0)