File: specialize_opaque_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 (45 lines) | stat: -rw-r--r-- 2,058 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
// RUN: %target-sil-opt -enable-sil-opaque-values -enable-sil-verify-all -generic-specializer %s | %FileCheck %s

sil_stage raw

import Builtin

// Test that foo is specialized on Builtin.Int64 and the copy_values and destroy_values are dropped.
//
// CHECK-LABEL: sil shared [ossa] @$s3fooBi64__Tg5 : $@convention(thin) (Builtin.Int64, Builtin.Int64) -> () {
// CHECK: bb0(%0 : $Builtin.Int64, %1 : $Builtin.Int64):
// CHECK:   [[F:%.*]] = function_ref @$s3fooBi64__Tg5 : $@convention(thin) (Builtin.Int64, Builtin.Int64) -> ()
// CHECK:   %{{.*}} = apply [[F]](%0, %1) : $@convention(thin) (Builtin.Int64, Builtin.Int64) -> ()
// CHECK-NOT: copy_value
// CHECK-NOT: destroy_value
// CHECK:   return %{{.*}} : $()
// CHECK: } // end sil function '$s3fooBi64__Tg5'

// Test that foo when specialized on Builtin.NativeObject, keeps copy_value/etc.
// CHECK-LABEL: sil shared [ossa] @$s3fooBo_Tg5 : $@convention(thin) (@owned Builtin.NativeObject, @owned Builtin.NativeObject) -> () {
// CHECK: copy_value
// CHECK: apply
// CHECK: destroy_value
// CHECK: } // end sil function '$s3fooBo_Tg5'

sil hidden [ossa] @foo : $@convention(thin) <T> (@in T, @in T) -> () {
bb0(%0 : @owned $T, %1 : @owned $T):
  %f = function_ref @foo : $@convention(thin) <τ_0_0> (@in τ_0_0, @in τ_0_0) -> ()
  %cp0 = copy_value %0 : $T
  %cp1 = copy_value %1 : $T
  %call = apply %f<T>(%cp0, %cp1) : $@convention(thin) <τ_0_0> (@in τ_0_0, @in τ_0_0) -> ()
  destroy_value %1 : $T
  destroy_value %0 : $T
  %10 = tuple ()
  return %10 : $()
}

sil [ossa] @testSpecialize : $@convention(thin) (Builtin.Int64, @owned Builtin.NativeObject) -> () {
bb0(%0 : $Builtin.Int64, %1 : @owned $Builtin.NativeObject):
  %f = function_ref @foo : $@convention(thin) <T> (@in T, @in T) -> ()
  %call = apply %f<Builtin.Int64>(%0, %0) : $@convention(thin) <τ_0_0> (@in τ_0_0, @in τ_0_0) -> ()
  %1a = copy_value %1 : $Builtin.NativeObject
  %call2 = apply %f<Builtin.NativeObject>(%1, %1a) : $@convention(thin) <τ_0_0> (@in τ_0_0, @in τ_0_0) -> ()
  %999 = tuple ()
  return %999 : $()
}