File: sil_combine_devirt_ossa.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 (58 lines) | stat: -rw-r--r-- 1,976 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
// RUN: %target-sil-opt -enable-sil-verify-all %s -devirtualizer | %FileCheck %s

sil_stage canonical

import Builtin
import Swift

/*
class Foo {
  var m_val : Int32
  init(x : Int32) { m_val = x }
  func get() -> Int32 {return m_val}
}
func test_me(x : Int32) -> Foo { return Foo(x) }
func main() { print(test_me(3).get()) }
*/

class Foo {
  var m_val: Int32
  init(x: Int32)
  func get() -> Int32
}

//CHECK: _TF4main4mainFT_T_
//CHECK: function_ref @_TFC4main3Foo3getfS0_FT_Si
//CHECK: return
sil [ossa] @_TF4main4mainFT_T_ : $@convention(thin) () -> () {
bb0:
  // function_ref swift
  %0 = function_ref @_Ts5printFT3valSi_T_ : $@convention(thin) (Int32) -> () // user: %8
  %1 = integer_literal $Builtin.Int32, 3          // user: %2
  %2 = struct $Int32 (%1 : $Builtin.Int32)        // user: %5
  %3 = alloc_ref $Foo                             // users: %6, %7, %4
  %3a = begin_borrow %3 : $Foo
  %4 = ref_element_addr %3a : $Foo, #Foo.m_val     // user: %5
  store %2 to [trivial] %4 : $*Int32                        // id: %5
  end_borrow %3a : $Foo
  %6 = class_method %3 : $Foo, #Foo.get : (Foo) -> () -> Int32, $@convention(method) (@guaranteed Foo) -> Int32 // user: %7
  %7 = apply %6(%3) : $@convention(method) (@guaranteed Foo) -> Int32 // user: %8
  %8 = apply %0(%7) : $@convention(thin) (Int32) -> ()
  %9 = tuple ()                                   // user: %10
  destroy_value %3 : $Foo
  return %9 : $()                                 // id: %10
}

sil [ossa] @_Ts5printFT3valSi_T_ : $@convention(thin) (Int32) -> ()

// main.Foo.get (main.Foo)() -> Swift.Int32
sil [noinline] [ossa]  @_TFC4main3Foo3getfS0_FT_Si : $@convention(method) (@guaranteed Foo) -> Int32 {
bb0(%0 : @guaranteed $Foo):
  %1 = ref_element_addr %0 : $Foo, #Foo.m_val     // user: %2
  %2 = load [trivial] %1 : $*Int32                          // user: %4
  return %2 : $Int32                              // id: %4
}

sil_vtable Foo {
  #Foo.get: @_TFC4main3Foo3getfS0_FT_Si
}