File: mem2reg_unreachable_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 (68 lines) | stat: -rw-r--r-- 1,890 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
59
60
61
62
63
64
65
66
67
68
// RUN: %target-sil-opt -enable-sil-verify-all %s -mem2reg

// Make sure we are not crashing on blocks that are not dominated by the entry block.

sil_stage canonical

import Builtin
import Swift

// CHECK-LABEL: sil [ossa] @_TF4main3fooFT1xSi1ySi_Si : 
// CHECK-NEXT: alloc_stack
// CHECK-LABEL: } // end sil function '_TF4main3fooFT1xSi1ySi_Si'
sil [ossa] @_TF4main3fooFT1xSi1ySi_Si : $@convention(thin) (Int32, Int32) -> Int32 {
bb0(%0 : $Int32, %1 : $Int32):
  debug_value %0 : $Int32, let, name "x"
  debug_value %1 : $Int32, let, name "y"
  %4 = alloc_stack $Int32, var, name "g"
  %6 = struct_extract %1 : $Int32, #Int32._value
  %7 = struct_extract %0 : $Int32, #Int32._value
  %8 = builtin "cmp_sgt_Word"(%6 : $Builtin.Int32, %7 : $Builtin.Int32) : $Builtin.Int1
  %9 = struct $Bool (%8 : $Builtin.Int1)
  %10 = struct_extract %9 : $Bool, #Bool._value
  br bb2

// bb1 is unreachable
// CHECK-LABEL: bb1:
// CHECK-NEXT: br bb3
bb1:
  %12 = integer_literal $Builtin.Int32, 5
  %13 = struct $Int32 (%12 : $Builtin.Int32)
  store %13 to [trivial] %4 : $*Int32
  br bb3

bb2:
  %16 = integer_literal $Builtin.Int32, 4
  %17 = struct $Int32 (%16 : $Builtin.Int32)
  store %17 to [trivial] %4 : $*Int32
  br bb3

bb3:
  %20 = load [trivial] %4 : $*Int32
  dealloc_stack %4 : $*Int32
  return %20 : $Int32
}

struct S {}

// CHECK-LABEL: sil hidden [ossa] @handle_unreachable :
// CHECK-NOT: alloc_stack
// CHECK: debug_value undef : $S, let, name "newvalue", argno 1
// CHECK-LABEL: } // end sil function 'handle_unreachable'
sil hidden [ossa] @handle_unreachable : $@convention(thin) () -> () {
bb0:
  %0 = alloc_stack $S, var, name "x"
  %1 = struct $S ()
  store %1 to [trivial] %0 : $*S
  unreachable

bb1:
  debug_value %0 : $*S, let, name "newvalue", argno 1, expr op_deref
  br bb2

bb2:
  %3 = load [trivial] %0 : $*S
  dealloc_stack %0 : $*S
  %4 = tuple ()
  return %4 : $()
}