File: mandatory_devirt_witness_method.sil

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (59 lines) | stat: -rw-r--r-- 2,110 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
// RUN: %target-sil-opt -module-name=test -enable-sil-verify-all %s -mandatory-performance-optimizations -performance-diagnostics | %FileCheck %s

sil_stage canonical

import Swift
import SwiftShims
import Builtin

public protocol P {
  func foo()
}

private struct S : P {
  @_hasStorage var x: Int
  func foo()
}

// Linkage should be set to public
// CHECK-LABEL: sil [perf_constraint] [ossa] @S_foo : $@convention(method) (S) -> () {
sil private [ossa] @S_foo : $@convention(method) (S) -> () {
bb0(%0 : $S):
  %2 = tuple ()
  return %2 : $()
}

sil private [transparent] [thunk] [ossa] @S_foo_thunk : $@convention(witness_method: P) (@in_guaranteed S) -> () {
bb0(%0 : $*S):
  %1 = load [trivial] %0 : $*S
  %2 = function_ref @S_foo : $@convention(method) (S) -> ()
  %3 = apply %2(%1) : $@convention(method) (S) -> ()
  %4 = tuple ()
  return %4 : $()
}

// CHECK-LABEL: sil shared [serialized] [perf_constraint] [ossa] @$s8call_foo4test1S{{.*}}_Tgq5 : $@convention(thin) (S) -> () {
// CHECK:         [[F:%.*]] = function_ref @S_foo : $@convention(method) (S) -> ()
// CHECK:         = apply [[F]](%0) : $@convention(method) (S) -> ()
// CHECK:       // end sil function '$s8call_foo4test1S{{.*}}_Tgq5'
sil [ossa] [serialized] @call_foo : $@convention(thin) <T where T : P> (@in_guaranteed T) -> () {
bb0(%0 : $*T):
  %2 = witness_method $T, #P.foo : <Self where Self : P> (Self) -> () -> () : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
  %3 = apply %2<T>(%0) : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
  %4 = tuple ()
  return %4 : $()
}

sil [no_locks] [ossa] [serialized] @main : $@convention(thin) (@in_guaranteed S) -> () {
bb0(%0 : $*S):
  %5 = function_ref @call_foo : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
  %6 = apply %5<S>(%0) : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
  %8 = tuple ()
  return %8 : $()
}

sil_witness_table private S: P module test {
  method #P.foo: <Self where Self : P> (Self) -> () -> () : @S_foo_thunk	
}