File: eager_specialize_ossa_attr.sil

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 (68 lines) | stat: -rw-r--r-- 2,178 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
// RUN: %target-sil-opt -enable-sil-verify-all -eager-specializer  %s | %FileCheck %s

import Swift

public protocol AnElt {
}

public protocol HasElt {
  associatedtype Elt
  init(e: Elt)
}

struct X : AnElt {
  @_hasStorage var i: Int { get set }
  init(i: Int)
}

struct S : HasElt {
  typealias Elt = X
  @_hasStorage var e: X { get set }
  init(e: Elt)
}

class Klass {}

class EltTrivialKlass : AnElt {
  var i: Int { get set }
  init(i: Int) {}
}

class ContainerKlass : HasElt {
  typealias Elt = EltTrivialKlass
  var e: Elt { get set }
  required init(e: Elt)
}

public struct G<Container : HasElt> {
  var container: Container? = nil
  public func getContainer(e: Container.Elt) -> Container
  init()
}

public struct GTrivial<Container : HasElt> {
  public func getContainer(e: Container.Elt) -> Container
  init()
}

sil [ossa] @callee : $@convention(method) <Container where Container : HasElt> (@in Container.Elt, @in_guaranteed G<Container>) -> @out Container {
bb0(%0 : $*Container, %1 : $*Container.Elt, %2 : $*G<Container>):
  %4 = witness_method $Container, #HasElt.init!allocator : $@convention(witness_method: HasElt) <τ_0_0 where τ_0_0 : HasElt> (@in τ_0_0.Elt, @thick τ_0_0.Type) -> @out τ_0_0
  %5 = metatype $@thick Container.Type
  %6 = apply %4<Container>(%0, %1, %5) : $@convention(witness_method: HasElt) <τ_0_0 where τ_0_0 : HasElt> (@in τ_0_0.Elt, @thick τ_0_0.Type) -> @out τ_0_0
  %7 = tuple ()
  return %7 : $()
}

// CHECK-LABEL: sil {{.*}}@$s6caller4main1SV_Tg5 : {{.*}}{
// CHECK:       {{bb[0-9]+}}({{%[^,]+}} : @_eagerMove $G<S>, {{%[^,]+}} :
// CHECK-LABEL: } // end sil function '$s6caller4main1SV_Tg5'

sil [_specialize where T == S] [ossa] @caller : $@convention(thin) <T where T : HasElt, T.Elt : AnElt> (@in_guaranteed G<T>, @in T.Elt) -> @out T {
bb0(%0 : $*T, %1 : @_eagerMove $*G<T>, %2 : $*T.Elt):
  %5 = function_ref @callee : $@convention(method) <τ_0_0 where τ_0_0 : HasElt> (@in τ_0_0.Elt, @in_guaranteed G<τ_0_0>) -> @out τ_0_0
  %6 = apply %5<T>(%0, %2, %1) : $@convention(method) <τ_0_0 where τ_0_0 : HasElt> (@in τ_0_0.Elt, @in_guaranteed G<τ_0_0>) -> @out τ_0_0
  %7 = tuple ()
  return %7 : $()
}