File: devirt_class_witness_method.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 (90 lines) | stat: -rw-r--r-- 3,236 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
// RUN: %target-sil-opt -enable-sil-verify-all %/s -devirtualizer -sil-combine -enable-library-evolution -save-optimization-record-path=%t.opt.yaml | %FileCheck %s
sil_stage canonical
// RUN: %FileCheck -check-prefix=YAML -input-file=%t.opt.yaml %s

import Builtin
enum Error {}
protocol P {
  func f()
  func g() throws
}

extension P {
  func f()
  func g() throws
}

class C<T, U> : P {}

sil hidden_external [transparent] [thunk] @witness_thunk : $@convention(witness_method: P) <τ_0_0><τ_1_0, τ_1_1 where τ_0_0 : C<τ_1_0, τ_1_1>> (@in_guaranteed τ_0_0) -> ()
sil hidden_external [transparent] [thunk] @witness_thunk2 : $@convention(witness_method: P) <τ_0_0><τ_1_0, τ_1_1 where τ_0_0 : C<τ_1_0, τ_1_1>> (@in_guaranteed τ_0_0) -> ()

// CHECK-LABEL: sil hidden @caller : $@convention(thin) <T, U> (@owned C<T, U>) -> ()
// CHECK: [[FN:%.*]] = function_ref @witness_thunk
// CHECK: apply [[FN]]<C<T, U>, T, U>(
// CHECK: return

// CHECK-LABEL: sil hidden @caller2
// CHECK: witness_method
// CHECK: try_apply
// CHECK: return

// YAML:      --- !Passed
// YAML-NEXT: Pass:            sil-devirtualizer
// YAML-NEXT: Name:            sil.WitnessMethodDevirtualized
// YAML-NEXT: DebugLoc:
// YAML:        File:            {{.*}}/devirt_class_witness_method.sil
// YAML:        Line:            55
// YAML:        Column:          8
// YAML-NEXT: Function:        caller
// YAML-NEXT: Args:
// YAML-NEXT:   - String:          'Devirtualized call to '
// YAML-NEXT:   - Method:          '"witness_thunk"'
// YAML-NEXT:     DebugLoc:
// YAML:            File:            {{.*}}/devirt_class_witness_method.sil
// YAML:            Line:            19
// YAML:            Column:          44
// YAML-NEXT: ...

sil hidden @caller : $@convention(thin) <T, U> (@owned C<T, U>) -> () {
bb0(%0 : $C<T, U>):
  strong_retain %0 : $C<T, U>
  %4 = alloc_stack $C<T, U>
  store %0 to %4 : $*C<T, U>
  %6 = witness_method $C<T, U>, #P.f : <Self where Self : P> (Self) -> () -> () : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
  %7 = apply %6<C<T, U>>(%4) : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> ()
  dealloc_stack %4 : $*C<T, U>
  strong_release %0 : $C<T, U>
  %9 = tuple ()
  return %9 : $()
}

sil hidden @caller2 : $@convention(thin) <T, U> (@owned C<T, U>) -> () {
bb0(%0 : $C<T, U>):
  strong_retain %0 : $C<T, U>
  %4 = alloc_stack $C<T, U>
  store %0 to %4 : $*C<T, U>
  %6 = witness_method $C<T, U>, #P.g : <Self where Self : P> (Self) -> () throws -> () : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @error Error
  try_apply %6<C<T, U>>(%4) : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> @error Error, normal bb1, error bb2

bb1(%8 : $()):
  br bb3

bb2(%11 : $Error):
  br bb3

bb3:
  dealloc_stack %4 : $*C<T, U>
  strong_release %0 : $C<T, U>
  %9 = tuple ()
  return %9 : $()
}
sil_vtable C {}

sil_witness_table hidden <T, U> C<T, U>: P module clsx {
  method #P.f: <Self where Self : P> (Self) -> () -> () : @witness_thunk
  method #P.g: <Self where Self : P> (Self) -> () throws -> () : @witness_thunk2
}

sil_default_witness_table hidden P {
}