File: address_lowering_preprocessed.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 (37 lines) | stat: -rw-r--r-- 1,629 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
// RUN: %empty-directory(%t) 
// RUN: %target-sil-opt -test-runner -address-lowering -enable-sil-opaque-values -sil-disable-input-verify -emit-sorted-sil %s | %FileCheck %s

import Builtin
import Swift
import SwiftShims

struct Box<T> {
    var _value : T
}

// Verify that the isCopyValue assertion in
// AddressMaterialization::materializeDefProjection is not triggered.  This is
// possible because the destroy_value is rewritten last.  Rewriting it last
// enables the lifetime analysis done in isStoreCopy to remain valid until the
// lifetime-ending uses are rewritten.
// CHECK-LABEL: sil [ossa] @destroy_before_copy_in_use_list : {{.*}} {
// CHECK:       bb0([[T:%[^,]+]] : $*T, [[BOX:%[^,]+]] :
// CHECK:         [[FIELD_ADDR:%[^,]+]] = struct_element_addr [[BOX]] : {{.*}}, #Box._value
// CHECK:         copy_addr [[T]] to [[FIELD_ADDR]]
// CHECK:         [[RETVAL:%[^,]+]] = tuple ()
// CHECK:         destroy_addr [[T]]
// CHECK:         return [[RETVAL]]
// CHECK-LABEL: } // end sil function 'destroy_before_copy_in_use_list'
sil [ossa] @destroy_before_copy_in_use_list : $@convention(thin) <T> (@in T, @inout Box<T>) -> () {
bb0(%t : @owned $T, %box : $*Box<T>):
  // The destroy_value appears first in the textual SIL in order to be first in
  // the use list.  Before running AddressLowering, it's sunk to after the
  // end_access.
  specify_test "instruction-move-before @instruction @instruction[+5]"
  destroy_value %t : $T
  %copy = copy_value %t : $T
  %field_addr = struct_element_addr %box : $*Box<T>, #Box._value
  store %copy to [assign] %field_addr : $*T
  %retval = tuple ()
  return %retval : $()
}