mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
getVarInfo() now always returns a variable with a location and scope. To opt out of this change, getVarInfo(false) returns an incomplete variable. This can be used to work around bugs, but should only really be used for printing. The complete var info will also contain the type, except for debug_values, as its type depends on another instruction, which may be inconsistent if called mid-pass. All locations in debug variables are now also stripped of flags, to avoid issues when comparing or hashing debug variables.
40 lines
1.7 KiB
Plaintext
40 lines
1.7 KiB
Plaintext
// RUN: %target-sil-opt -enable-sil-verify-all -deadobject-elim %s | %FileCheck %s
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
import Swift
|
|
|
|
struct MyObject {
|
|
var _storage: (UInt8, UInt8)
|
|
}
|
|
|
|
// CHECK-LABEL: sil @$myFunc
|
|
sil @$myFunc : $@convention(thin) (UInt8) -> UInt8 {
|
|
[global: ]
|
|
bb0(%0 : $UInt8):
|
|
debug_value %0 : $UInt8, let, name "value", argno 1
|
|
// CHECK-NOT: alloc_stack
|
|
%2 = alloc_stack $MyObject, var, name "obj"
|
|
%24 = integer_literal $Builtin.Int8, 3
|
|
%25 = struct_extract %0 : $UInt8, #UInt8._value
|
|
%26 = integer_literal $Builtin.Int1, -1
|
|
%27 = builtin "uadd_with_overflow_Int8"(%25 : $Builtin.Int8, %24 : $Builtin.Int8, %26 : $Builtin.Int1) : $(Builtin.Int8, Builtin.Int1)
|
|
%28 = tuple_extract %27 : $(Builtin.Int8, Builtin.Int1), 0
|
|
%29 = tuple_extract %27 : $(Builtin.Int8, Builtin.Int1), 1
|
|
cond_fail %29 : $Builtin.Int1, "arithmetic overflow"
|
|
%31 = struct $UInt8 (%28 : $Builtin.Int8)
|
|
%34 = struct_element_addr %2 : $*MyObject, #MyObject._storage
|
|
%35 = tuple_element_addr %34 : $*(UInt8, UInt8), 0
|
|
%36 = tuple_element_addr %34 : $*(UInt8, UInt8), 1
|
|
// The store below should be replaced by a debug_value with the same operand as the store (%0)
|
|
// The fragment refers to the member being modified
|
|
// CHECK-NOT: store
|
|
// CHECK: debug_value %0 : $UInt8, var, name "obj", type $MyObject, expr op_fragment:#MyObject._storage:op_tuple_fragment:$(UInt8, UInt8):1
|
|
store %0 to %36 : $*UInt8
|
|
// CHECK: debug_value %{{[0-9]}} : $UInt8, var, name "obj", type $MyObject, expr op_fragment:#MyObject._storage:op_tuple_fragment:$(UInt8, UInt8):0
|
|
store %31 to %35 : $*UInt8
|
|
dealloc_stack %2 : $*MyObject
|
|
return %31 : $UInt8
|
|
} // end sil function '$myFunc'
|