|
| 1 | +// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -simplification -simplify-instruction=builtin -sil-print-debuginfo | %FileCheck %s |
| 2 | + |
| 3 | +// REQUIRES: swift_in_compiler |
| 4 | + |
| 5 | +import Swift |
| 6 | +import Builtin |
| 7 | + |
| 8 | +// This verifies that debug information attached to the arguments of builtin |
| 9 | +// instructions is preserved when those instructions are constant-folded. |
| 10 | +// |
| 11 | +// CHECK-LABEL: sil @preserve_bitwise_operands : $@convention(thin) () -> Builtin.Int32 { |
| 12 | +// CHECK: bb0: |
| 13 | +// CHECK-NEXT: debug_value undef : $Builtin.Int32, let, name "x", expr op_constu:1 |
| 14 | +// CHECK-NEXT: debug_value undef : $Builtin.Int32, let, name "y", expr op_constu:2 |
| 15 | +// CHECK-NEXT: [[THREE:%[0-9]+]] = integer_literal $Builtin.Int32, 3 |
| 16 | +// CHECK-NEXT: return [[THREE]] : $Builtin.Int32 |
| 17 | +// CHECK-LABEL: } // end sil function 'preserve_bitwise_operands' |
| 18 | +sil @preserve_bitwise_operands : $@convention(thin) () -> Builtin.Int32 { |
| 19 | +bb0: |
| 20 | + %0 = integer_literal $Builtin.Int32, 1 |
| 21 | + debug_value %0, let, name "x" |
| 22 | + %1 = integer_literal $Builtin.Int32, 2 |
| 23 | + debug_value %1, let, name "y" |
| 24 | + %2 = builtin "or_Int32"(%0, %1) : $Builtin.Int32 |
| 25 | + return %2 |
| 26 | +} |
| 27 | + |
| 28 | +// CHECK-LABEL: sil @preserve_add_operands : $@convention(thin) () -> Builtin.Int32 { |
| 29 | +// CHECK: bb0: |
| 30 | +// CHECK-NEXT: debug_value undef : $Builtin.Int32, let, name "x", expr op_consts:4294967295 |
| 31 | +// CHECK-NEXT: debug_value undef : $Builtin.Int32, let, name "y", expr op_constu:2 |
| 32 | +// CHECK-NEXT: [[ONE:%[0-9]+]] = integer_literal $Builtin.Int32, 1 |
| 33 | +// CHECK-NEXT: return [[ONE]] : $Builtin.Int32 |
| 34 | +// CHECK-LABEL: } // end sil function 'preserve_add_operands' |
| 35 | +sil @preserve_add_operands : $@convention(thin) () -> Builtin.Int32 { |
| 36 | +bb0: |
| 37 | + %0 = integer_literal $Builtin.Int32, -1 |
| 38 | + debug_value %0, let, name "x" |
| 39 | + %1 = integer_literal $Builtin.Int32, 2 |
| 40 | + debug_value %1, let, name "y" |
| 41 | + %2 = builtin "add_Int32"(%0, %1) : $Builtin.Int32 |
| 42 | + return %2 |
| 43 | +} |
0 commit comments