|
1 | 1 | // RUN: %target-sil-opt -enable-sil-verify-all -sil-print-debuginfo -diagnostic-constant-propagation %s | %FileCheck %s |
2 | | -// REQUIRES: CPU=arm64 || CPU=x86_64 |
3 | 2 |
|
4 | 3 | sil_stage canonical |
5 | 4 |
|
6 | 5 | import Builtin |
7 | 6 | import Swift |
8 | 7 | import SwiftShims |
9 | 8 |
|
10 | | -func foo(x: Int, y: Int) -> Int |
11 | | - |
12 | | -sil_scope 1 { loc "file.swift":1:6 parent @foo : $@convention(thin) (Int, Int) -> Int } |
| 9 | +sil_scope 1 { loc "file.swift":1:6 parent @foo : $@convention(thin) (Int64, Int64) -> Int64 } |
13 | 10 |
|
14 | 11 | // Test if debug_value got preserved when %16 is removed in favor of directly using %13 |
15 | 12 | // CHECK-LABEL: sil {{.*}} @foo |
16 | | -sil hidden @foo : $@convention(thin) (Int, Int) -> Int { |
17 | | -bb0(%0 : $Int, %1 : $Int): |
| 13 | +sil hidden @foo : $@convention(thin) (Int64, Int64) -> Int64 { |
| 14 | +bb0(%0 : $Int64, %1 : $Int64): |
18 | 15 | %4 = integer_literal $Builtin.Int64, 87, loc "file.swift":2:17, scope 1 |
19 | | - %9 = struct_extract %0 : $Int, #Int._value, loc "file.swift":2:15, scope 1 |
| 16 | + %9 = struct_extract %0 : $Int64, #Int64._value, loc "file.swift":2:15, scope 1 |
20 | 17 | %11 = integer_literal $Builtin.Int1, -1, loc "file.swift":2:15, scope 1 |
21 | 18 | // CHECK: %[[ADD:.+]] = builtin "sadd_with_overflow |
22 | 19 | %12 = builtin "sadd_with_overflow_Int64"(%9 : $Builtin.Int64, %4 : $Builtin.Int64, %11 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1), loc "file.swift":2:15, scope 1 |
23 | 20 | // CHECK: (%[[RESULT:.+]], %{{.*}}) = destructure_tuple %[[ADD]] |
24 | 21 | (%13, %14) = destructure_tuple %12 : $(Builtin.Int64, Builtin.Int1), loc "file.swift":2:15, scope 1 |
25 | | - %16 = struct $Int (%13 : $Builtin.Int64), loc "file.swift":2:15, scope 1 |
| 22 | + %16 = struct $Int64 (%13 : $Builtin.Int64), loc "file.swift":2:15, scope 1 |
26 | 23 | // In addition to checking if `op_fragment` is generated, we're also checking if "z"'s declared |
27 | 24 | // source location, as well as `debug_value`'s instruction source location are preserved. |
28 | | - // CHECK: debug_value %[[RESULT]] : $Builtin.Int{{[0-9]+}}, let, name "z" |
29 | | - // CHECK-SAME: type $Int |
30 | | - // CHECK-SAME: expr op_fragment:#Int._value |
| 25 | + // CHECK: debug_value %[[RESULT]] : $Builtin.Int64, let, name "z" |
| 26 | + // CHECK-SAME: type $Int64 |
| 27 | + // CHECK-SAME: expr op_fragment:#Int64._value |
31 | 28 | // CHECK-SAME: loc "file.swift":2:9, scope 1 |
32 | | - debug_value %16 : $Int, let, name "z", loc "file.swift":2:9, scope 1 |
33 | | - %19 = struct_extract %16 : $Int, #Int._value, loc "file.swift":3:14, scope 1 |
34 | | - %20 = struct_extract %1 : $Int, #Int._value, loc "file.swift":3:14, scope 1 |
| 29 | + debug_value %16 : $Int64, let, name "z", loc "file.swift":2:9, scope 1 |
| 30 | + %19 = struct_extract %16 : $Int64, #Int64._value, loc "file.swift":3:14, scope 1 |
| 31 | + %20 = struct_extract %1 : $Int64, #Int64._value, loc "file.swift":3:14, scope 1 |
35 | 32 | %21 = integer_literal $Builtin.Int1, -1, loc "file.swift":3:14, scope 1 |
36 | 33 | %22 = builtin "sadd_with_overflow_Int64"(%19 : $Builtin.Int64, %20 : $Builtin.Int64, %21 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1), loc "file.swift":3:14, scope 1 |
37 | 34 | (%23, %24) = destructure_tuple %22 : $(Builtin.Int64, Builtin.Int1), loc "file.swift":3:14, scope 1 |
38 | | - %26 = struct $Int (%23 : $Builtin.Int64), loc "file.swift":3:14, scope 1 |
39 | | - return %26 : $Int, loc "file.swift":3:5, scope 1 |
| 35 | + %26 = struct $Int64 (%23 : $Builtin.Int64), loc "file.swift":3:14, scope 1 |
| 36 | + return %26 : $Int64, loc "file.swift":3:5, scope 1 |
40 | 37 | } // end sil function 'foo' |
41 | 38 |
|
| 39 | +sil_scope 2 { loc "file.swift":1:6 parent @bar : $@convention(thin) (Int64, Int64) -> Int64 } |
| 40 | + |
| 41 | +// Test if debug_value got preserved when %5 is folded into %0, and %3 removed |
| 42 | +// CHECK-LABEL: sil {{.*}} @bar |
| 43 | +sil hidden @bar : $@convention(thin) (Int64, Int64) -> Int64 { |
| 44 | +bb0(%0 : $Int64, %1 : $Int64): |
| 45 | + %3 = tuple $(low: Int64, high: Int64) (%0, %1), loc "file.swift":14:5, scope 2 |
| 46 | + // CHECK: debug_value %0 : $Int64, let, name "newValue" |
| 47 | + // CHECK-SAME: type $(low: Int64, high: Int64) |
| 48 | + // CHECK-SAME: expr op_tuple_fragment:$(low: Int64, high: Int64):0 |
| 49 | + // CHECK-SAME: "file.swift":14:5, scope 2 |
| 50 | + // CHECK: debug_value %1 : $Int64, let, name "newValue" |
| 51 | + // CHECK-SAME: type $(low: Int64, high: Int64) |
| 52 | + // CHECK-SAME: expr op_tuple_fragment:$(low: Int64, high: Int64):1 |
| 53 | + // CHECK-SAME: "file.swift":14:5, scope 2 |
| 54 | + debug_value %3 : $(low: Int64, high: Int64), let, name "newValue", argno 1, loc "file.swift":14:5, scope 2 |
| 55 | + (%5, %6) = destructure_tuple %3 : $(low: Int64, high: Int64), loc "file.swift":15:5, scope 2 |
| 56 | + return %5 : $Int64, loc "file.swift":15:5, scope 2 |
| 57 | +} // end sil function 'bar' |
0 commit comments