File: dead-obj-elim.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 (39 lines) | stat: -rw-r--r-- 1,694 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
// RUN: %target-sil-opt -enable-sil-verify-all -deadobject-elim %s | %FileCheck %s

sil_stage canonical

import Builtin
import Swift

struct MyObject {
  var _storage: (UInt8, UInt8)
}

// CHECK-LABEL: sil @$myFunc
sil @$myFunc : $@convention(thin) (UInt8) -> UInt8 {
[global: ]
bb0(%0 : $UInt8):
  debug_value %0 : $UInt8, let, name "value", argno 1
  // CHECK-NOT: alloc_stack
  %2 = alloc_stack $MyObject, var, name "obj"
  %24 = integer_literal $Builtin.Int8, 3
  %25 = struct_extract %0 : $UInt8, #UInt8._value
  %26 = integer_literal $Builtin.Int1, -1
  %27 = builtin "uadd_with_overflow_Int8"(%25 : $Builtin.Int8, %24 : $Builtin.Int8, %26 : $Builtin.Int1) : $(Builtin.Int8, Builtin.Int1)
  %28 = tuple_extract %27 : $(Builtin.Int8, Builtin.Int1), 0
  %29 = tuple_extract %27 : $(Builtin.Int8, Builtin.Int1), 1
  cond_fail %29 : $Builtin.Int1, "arithmetic overflow"
  %31 = struct $UInt8 (%28 : $Builtin.Int8)
  %34 = struct_element_addr %2 : $*MyObject, #MyObject._storage
  %35 = tuple_element_addr %34 : $*(UInt8, UInt8), 0
  %36 = tuple_element_addr %34 : $*(UInt8, UInt8), 1
  // The store below should be replaced by a debug_value with the same operand as the store (%0)
  // The fragment refers to the member being modified
  // CHECK-NOT: store
  // CHECK: debug_value %0 : $UInt8, var, name "obj", type $MyObject, expr op_fragment:#MyObject._storage:op_tuple_fragment:$(UInt8, UInt8):1
  store %0 to %36 : $*UInt8
  // CHECK: debug_value %{{[0-9]}} : $UInt8, var, name "obj", type $MyObject, expr op_fragment:#MyObject._storage:op_tuple_fragment:$(UInt8, UInt8):0
  store %31 to %35 : $*UInt8
  dealloc_stack %2 : $*MyObject
  return %31 : $UInt8
} // end sil function '$myFunc'