Skip to content

Commit 0712df9

Browse files
committed
Add testTrap SILCombine (DCE) test case
Before isReadOnlyConstantEvaluableCall is fixed to recognize that [_semantics "programtermination_point"] is not a read-only function, this test will fail as soon as SILCombine is fixed to recognize all dead code (e.g. by using the InstructionDeleter API).
1 parent f512beb commit 0712df9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/SILOptimizer/sil_combine_ossa.sil

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5219,3 +5219,22 @@ bb0(%0 : @owned $Klass, %1 : $Builtin.Word):
52195219
destroy_value %0 : $Klass
52205220
return %11 : $AnyObject
52215221
}
5222+
5223+
// Test that DCE during SILCombine does not remove traps.
5224+
// Tests isReadOnlyConstantEvaluable().
5225+
sil hidden [noinline] [_semantics "programtermination_point"] @trapWrapper : $@convention(thin) () -> () {
5226+
bb0:
5227+
%0 = builtin "int_trap"() : $Never
5228+
unreachable
5229+
}
5230+
5231+
// CHECK-LABEL: sil [ossa] @testTrap : $@convention(thin) () -> () {
5232+
// CHECK: apply
5233+
// CHECK-LABEL: } // end sil function 'testTrap'
5234+
sil [ossa] @testTrap : $@convention(thin) () -> () {
5235+
bb0:
5236+
%0 = function_ref @trapWrapper : $@convention(thin) () -> ()
5237+
%1 = apply %0() : $@convention(thin) () -> ()
5238+
%2 = tuple ()
5239+
return %2 : $()
5240+
}

0 commit comments

Comments
 (0)