mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
42 lines
2.3 KiB
Plaintext
42 lines
2.3 KiB
Plaintext
// RUN: %target-sil-opt -enable-sil-verify-all -sil-print-debuginfo -diagnostic-constant-propagation %s | %FileCheck %s
|
|
// REQUIRES: CPU=arm64 || CPU=x86_64
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
import Swift
|
|
import SwiftShims
|
|
|
|
func foo(x: Int, y: Int) -> Int
|
|
|
|
sil_scope 1 { loc "file.swift":1:6 parent @foo : $@convention(thin) (Int, Int) -> Int }
|
|
|
|
// Test if debug_value got preserved when %16 is removed in favor of directly using %13
|
|
// CHECK-LABEL: sil {{.*}} @foo
|
|
sil hidden @foo : $@convention(thin) (Int, Int) -> Int {
|
|
bb0(%0 : $Int, %1 : $Int):
|
|
%4 = integer_literal $Builtin.Int64, 87, loc "file.swift":2:17, scope 1
|
|
%9 = struct_extract %0 : $Int, #Int._value, loc "file.swift":2:15, scope 1
|
|
%11 = integer_literal $Builtin.Int1, -1, loc "file.swift":2:15, scope 1
|
|
// CHECK: %[[ADD:.+]] = builtin "sadd_with_overflow
|
|
%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
|
|
// CHECK: (%[[RESULT:.+]], %{{.*}}) = destructure_tuple %[[ADD]]
|
|
(%13, %14) = destructure_tuple %12 : $(Builtin.Int64, Builtin.Int1), loc "file.swift":2:15, scope 1
|
|
%16 = struct $Int (%13 : $Builtin.Int64), loc "file.swift":2:15, scope 1
|
|
// In addition to checking if `op_fragment` is generated, we're also checking if "z"'s declared
|
|
// source location, as well as `debug_value`'s instruction source location are preserved.
|
|
// CHECK: debug_value %[[RESULT]] : $Builtin.Int{{[0-9]+}}, let, name "z"
|
|
// CHECK-SAME: type $Int
|
|
// CHECK-SAME: expr op_fragment:#Int._value
|
|
// CHECK-SAME: loc "file.swift":2:9, scope 1
|
|
debug_value %16 : $Int, let, name "z", loc "file.swift":2:9, scope 1
|
|
%19 = struct_extract %16 : $Int, #Int._value, loc "file.swift":3:14, scope 1
|
|
%20 = struct_extract %1 : $Int, #Int._value, loc "file.swift":3:14, scope 1
|
|
%21 = integer_literal $Builtin.Int1, -1, loc "file.swift":3:14, scope 1
|
|
%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
|
|
(%23, %24) = destructure_tuple %22 : $(Builtin.Int64, Builtin.Int1), loc "file.swift":3:14, scope 1
|
|
%26 = struct $Int (%23 : $Builtin.Int64), loc "file.swift":3:14, scope 1
|
|
return %26 : $Int, loc "file.swift":3:5, scope 1
|
|
} // end sil function 'foo'
|
|
|