File: debug_value_addr.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (39 lines) | stat: -rw-r--r-- 1,391 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// RUN: %target-swift-frontend -primary-file %s -emit-ir -g -o - | %FileCheck %s
// RUN: %target-swift-frontend %s -emit-sil -g -o - | %FileCheck -check-prefix=CHECK-SIL %s

// Verify that -Onone shadow copies are emitted for debug_value_addr
// instructions.

// CHECK-SIL: sil hidden @$s16debug_value_addr4testyyxlF
// CHECK-SIL: debug_value %0 : $*T, let, name "t", {{.*}}, expr op_deref

// CHECK: define {{.*}}$s16debug_value_addr4testyyxlF
// CHECK: entry:
// CHECK-NEXT: %[[TADDR:.*]] = alloca
// CHECK-NEXT: call void @llvm.dbg.declare({{.*}}%[[TADDR]]
// CHECK: store ptr %0, ptr %[[TADDR:.*]], align

struct S<T> {
  var a : T
  func foo() {}
}

func test<T>(_ t : T) {
  let a = S(a: t)
  a.foo()
}

func use<T>(_ t : T) {}

// CHECK-SIL: sil hidden @$s16debug_value_addr11GenericSelfV1xACyxGx_tcfC : $@convention(method) <T> (@in T, @thin GenericSelf<T>.Type) -> GenericSelf<T> {
// CHECK-SIL: bb0(%0 : $*T, %1 : $@thin GenericSelf<T>.Type):
// TODO: Why is the type repeated below?
// CHECK-SIL-NEXT:  alloc_stack [var_decl] $GenericSelf<T>, var, name "self", type $GenericSelf<T>, loc {{.*}}
// CHECK-SIL-NEXT:  debug_value %0 : $*T, let, name "x", argno 1, expr op_deref, loc {{.*}}
struct GenericSelf<T> {
  init(x: T) {
    // 'self' is a valid debug variable here even though there is
    // nothing to initialize (the dead alloc_stack cannot be removed).
    use(x)
  }
}