mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Type annotations for instruction operands are omitted, e.g. ``` %3 = struct $S(%1, %2) ``` Operand types are redundant anyway and were only used for sanity checking in the SIL parser. But: operand types _are_ printed if the definition of the operand value was not printed yet. This happens: * if the block with the definition appears after the block where the operand's instruction is located * if a block or instruction is printed in isolation, e.g. in a debugger The old behavior can be restored with `-Xllvm -sil-print-types`. This option is added to many existing test files which check for operand types in their check-lines.
38 lines
1.6 KiB
Plaintext
38 lines
1.6 KiB
Plaintext
// RUN: %empty-directory(%t)
|
|
// RUN: %target-sil-opt -sil-print-types -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 : $()
|
|
}
|