File: noimplicitcopy.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 (48 lines) | stat: -rw-r--r-- 2,073 bytes parent folder | download | duplicates (2)
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
// RUN: %target-sil-opt -enable-experimental-move-only -enable-sil-verify-all -sil-move-only-object-checker %s

//////////////////
// Declarations //
//////////////////

class Klass {}

struct CopyableStruct {
  var k = Klass()
}

sil @classUseMoveOnlyWithoutEscaping : $@convention(thin) (@guaranteed Klass) -> ()

///////////
// Tests //
///////////

// This test makes sure that we eliminate %2 after checking and that
// sil-verify-all does not trigger.
sil [ossa] @test_remove_early_copyvalue : $@convention(thin) (@guaranteed Klass) -> () {
bb0(%0 : @noImplicitCopy @guaranteed $Klass):
  %1 = copyable_to_moveonlywrapper [guaranteed] %0 : $Klass
  %2 = copy_value %1 : $@moveOnly Klass
  %3 = mark_unresolved_non_copyable_value [no_consume_or_assign] %2 : $@moveOnly Klass
  debug_value %3 : $@moveOnly Klass, let, name "x2", argno 1
  %5 = begin_borrow %3 : $@moveOnly Klass
  %6 = function_ref @classUseMoveOnlyWithoutEscaping : $@convention(thin) (@guaranteed Klass) -> ()
  %7 = moveonlywrapper_to_copyable [guaranteed] %5 : $@moveOnly Klass
  %8 = apply %6(%7) : $@convention(thin) (@guaranteed Klass) -> ()
  end_borrow %5 : $@moveOnly Klass
  destroy_value %3 : $@moveOnly Klass
  %11 = tuple ()
  return %11 : $()
}

sil [ossa] @testSimpleBorrowParameter : $@convention(thin) (@in_guaranteed CopyableStruct) -> () {
bb0(%0 : @noImplicitCopy $*CopyableStruct):
  %1 = load_borrow %0 : $*CopyableStruct                       // users: %7, %2
  %2 = copyable_to_moveonlywrapper [guaranteed] %1 : $CopyableStruct // user: %3
  %3 = copy_value %2 : $@moveOnly CopyableStruct               // user: %4
  %4 = mark_unresolved_non_copyable_value [no_consume_or_assign] %3 : $@moveOnly CopyableStruct // users: %6, %5
  debug_value %4 : $@moveOnly CopyableStruct, let, name "x", argno 1 // id: %5
  destroy_value %4 : $@moveOnly CopyableStruct                 // id: %6
  end_borrow %1 : $CopyableStruct                              // id: %7
  %8 = tuple ()                                   // user: %9
  return %8 : $()                                 // id: %9
}