File: devirt_alloc_ref_dynamic_ownership.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 (41 lines) | stat: -rw-r--r-- 1,143 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
// RUN: %target-sil-opt -enable-sil-verify-all %s -sil-combine -devirtualizer -dce | %FileCheck %s

sil_stage canonical

import Builtin
import Swift
import SwiftShims

class A {
  init(m: Int)
  convenience init(n: Int)
  func foo() -> Int32
   deinit
}

// test.A.foo (test.A)() -> Swift.Int32
sil hidden [noinline] [ossa] @_TFC4test1A3foofS0_FT_Vs5Int32 : $@convention(method) (@guaranteed A) -> Int32 {
bb0(%0 : @guaranteed $A):
  %2 = integer_literal $Builtin.Int32, 1
  %3 = struct $Int32 (%2 : $Builtin.Int32)
  return %3 : $Int32
}

// CHECK-LABEL: @test_alloc_ref_dynamic_devirt
// CHECK-NOT: class_method
// CHECK: function_ref @_TFC4test1A3foofS0_FT_Vs5Int32
// CHECK: apply
// CHECK: return
sil [ossa] @test_alloc_ref_dynamic_devirt : $@convention(thin) () -> Int32 {
bb0:
  %1 = metatype $@thick A.Type
  %2 = alloc_ref_dynamic %1 : $@thick A.Type, $A
  %8 = class_method %2 : $A, #A.foo : (A) -> () -> Int32, $@convention(method) (@guaranteed A) -> Int32
  %9 = apply %8(%2) : $@convention(method) (@guaranteed A) -> Int32
  destroy_value %2 : $A
  return %9 : $Int32
}

sil_vtable A {
  #A.foo: @_TFC4test1A3foofS0_FT_Vs5Int32
}