File: consume_operator_kills_copyable_values.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 (47 lines) | stat: -rw-r--r-- 1,431 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
// RUN: %target-sil-opt -enable-sil-verify-all -o - -sil-consume-operator-copyable-values-checker -verify %s

// This file is meant for specific SIL patterns that may be hard to produce with
// the current swift frontend but have reproduced before and we want to make
// sure keep on working.

import Builtin

class Klass {}

struct Int {
  var _value: Builtin.Int64
}

enum Optional<T> {
case none
case some(T)
}

// Make sure that we only emit an error on the use within the loop and not on
// the destroy_value along the exit edge of the loop.
sil [ossa] @useInLoopWithDestroyOutOfLoop : $@convention(thin) (@guaranteed Klass) -> () {
bb0(%0 : @guaranteed $Klass):
  debug_value %0 : $Klass, let, name "x", argno 1
  %2 = begin_borrow [lexical] [var_decl] %0 : $Klass // expected-error {{'y' used after consume}}
  debug_value %2 : $Klass, let, name "y"
  %4 = copy_value %2 : $Klass
  %5 = move_value [allows_diagnostics] %4 : $Klass // expected-note {{consumed here}}
  destroy_value %5 : $Klass
  br bb1

bb1:
  switch_enum undef : $Optional<Int>, case #Optional.some!enumelt: bb2, case #Optional.none!enumelt: bb3

bb2(%58 : $Int):
  %59 = copy_value %2 : $Klass
  %60 = begin_borrow [lexical] [var_decl] %59 : $Klass // expected-note {{used here}}
  debug_value %60 : $Klass, let, name "m"
  end_borrow %60 : $Klass
  destroy_value %59 : $Klass
  br bb1

bb3:
  end_borrow %2 : $Klass
  %67 = tuple ()
  return %67 : $()
}