mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Change SILGen to emit the `debug_value` instruction using the original inout parameter address, instead of the `mark_must_check` inserted for move-only parameters, because code in the MoveOnlyAddressChecker did not expect to find the debug_value anywhere but on the original address. Update move-only diagnostics so that they pick up the declaration name for a memory location from any debug_value instruction if there are more than one. rdar://109740281
66 lines
1.8 KiB
Swift
66 lines
1.8 KiB
Swift
// RUN: %target-swift-frontend -emit-sil -g %s | %FileCheck %s
|
|
// RUN: %target-swift-frontend -DADDRESS_ONLY -emit-sil -g %s | %FileCheck %s
|
|
|
|
struct Foo: ~Copyable {
|
|
#if ADDRESS_ONLY
|
|
private var x: Any
|
|
#else
|
|
private var x: Int
|
|
#endif
|
|
}
|
|
|
|
@_silgen_name("use")
|
|
func use(_: inout Foo)
|
|
|
|
// CHECK-LABEL: sil {{.*}} @${{.*}}3bar
|
|
func bar(_ x: consuming Foo, y: consuming Foo, z: consuming Foo) {
|
|
// CHECK: [[X:%.*]] = alloc_stack{{.*}} $Foo, var, name "x"
|
|
|
|
// CHECK: [[USE:%.*]] = function_ref @use
|
|
// CHECK: apply [[USE]]
|
|
// CHECK: debug_value undef : $*Foo, var, name "x"
|
|
use(&x)
|
|
let _ = x
|
|
|
|
// CHECK: debug_value undef : $*Foo, var, name "y"
|
|
// CHECK: debug_value [[X]] : $*Foo, var, name "x"
|
|
x = y
|
|
// CHECK: [[USE:%.*]] = function_ref @use
|
|
// CHECK: apply [[USE]]
|
|
// CHECK: debug_value undef : $*Foo, var, name "x"
|
|
use(&x)
|
|
let _ = x
|
|
|
|
// CHECK: debug_value undef : $*Foo, var, name "z"
|
|
// CHECK: debug_value [[X]] : $*Foo, var, name "x"
|
|
x = z
|
|
// CHECK: [[USE:%.*]] = function_ref @use
|
|
// CHECK: apply [[USE]]
|
|
// CHECK: debug_value undef : $*Foo, var, name "x"
|
|
use(&x)
|
|
}
|
|
|
|
// CHECK-LABEL: sil {{.*}} @${{.*}}10inoutParam
|
|
func inoutParam(_ x: inout Foo, y: consuming Foo, z: consuming Foo) {
|
|
// CHECK: debug_value [[X:%[0-9]+]] : $*Foo, var, name "x"
|
|
|
|
// CHECK: [[USE:%.*]] = function_ref @use
|
|
// CHECK: apply [[USE]]
|
|
// CHECK: debug_value undef : $*Foo, var, name "x"
|
|
use(&x)
|
|
let _ = x
|
|
|
|
// CHECK: debug_value undef : $*Foo, var, name "y"
|
|
// CHECK: debug_value [[X]] : $*Foo, var, name "x"
|
|
x = y
|
|
// CHECK: [[USE:%.*]] = function_ref @use
|
|
// CHECK: apply [[USE]]
|
|
// CHECK: debug_value undef : $*Foo, var, name "x"
|
|
use(&x)
|
|
let _ = x
|
|
|
|
// CHECK: debug_value undef : $*Foo, var, name "z"
|
|
// CHECK: debug_value [[X]] : $*Foo, var, name "x"
|
|
x = z
|
|
}
|