File: attributes.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 (94 lines) | stat: -rw-r--r-- 3,037 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -emit-sil %s -verify -Osize -o /dev/null -module-name main
//
// NOTE: We only emit opt-remarks with -Osize,-O today! -O does drop way more
// stuff though, so we test with -Osize.

public class Klass {}

public var mySingleton = Klass()

@inline(never)
func getGlobal() -> Klass {
    return mySingleton
}

@inline(never)
func useKlass(_ k: Klass) {}

@_semantics("optremark")
@inline(never)
public func forceOptRemark() {
    let x = getGlobal()
    useKlass(x) // expected-remark {{release of type 'Klass'}}
                // expected-note @-2 {{of 'x'}}
}

@_semantics("optremark.sil-assembly-vision-remark-gen")
@inline(never)
public func forceOptRemark2() {
    let x = getGlobal()
    useKlass(x) // expected-remark {{release of type 'Klass'}}
                // expected-note @-2 {{of 'x'}}
}

@_semantics("optremark.fail")
@inline(never)
public func failMatch() {
    let x = getGlobal()
    useKlass(x)
}

@_semantics("optremark")
public func allocateInlineCallee() -> Klass {
    return Klass() // expected-remark {{"main.Klass.__allocating_init()" inlined into "main.allocateInlineCallee()"}}
                   // expected-remark @-1 {{heap allocated ref of type 'Klass'}}
}

@_semantics("optremark.sil-inliner")
public func allocateInlineCallee2() -> Klass {
    return Klass() // expected-remark {{"main.Klass.__allocating_init()" inlined into "main.allocateInlineCallee2()"}}
}

// This makes sure we don't emit any remarks if we do not have semantics.
public func allocateInlineCallee3() -> Klass {
    return Klass()
}

@_semantics("optremark.sil-inliner")
@_semantics("optremark.sil-assembly-vision-remark-gen")
public func mix1() -> (Klass, Klass) {
    let x = getGlobal()
    return (x, Klass()) // expected-remark {{"main.Klass.__allocating_init()" inlined into "main.mix1()"}}
                        // expected-remark @-1:16 {{heap allocated ref of type 'Klass'}}
}

@_semantics("optremark.sil-inliner")
public func mix2() -> (Klass, Klass) {
    let x = getGlobal()
    return (x, Klass()) // expected-remark {{"main.Klass.__allocating_init()" inlined into "main.mix2()"}}
}

@_semantics("optremark.sil-assembly-vision-remark-gen")
public func mix3() -> (Klass, Klass) {
    let x = getGlobal()
    return (x, Klass()) // expected-remark {{heap allocated ref of type 'Klass'}}
}

@_semantics("optremark")
public func mix4() -> (Klass, Klass) {
    let x = getGlobal()
    return (x, Klass()) // expected-remark {{"main.Klass.__allocating_init()" inlined into "main.mix4()"}}
                        // expected-remark @-1 {{heap allocated ref of type 'Klass'}}
}

public func mix5() -> (Klass, Klass) {
    let x = getGlobal()
    return (x, Klass())
}

@_assemblyVision
public func mix4a() -> (Klass, Klass) {
    let x = getGlobal()
    return (x, Klass()) // expected-remark {{"main.Klass.__allocating_init()" inlined into "main.mix4a()"}}
                        // expected-remark @-1 {{heap allocated ref of type 'Klass'}}
}