mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +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.
49 lines
2.5 KiB
Plaintext
49 lines
2.5 KiB
Plaintext
// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all -release-hoisting %s | %FileCheck %s
|
|
// REQUIRES: PTRSIZE=64
|
|
// REQUIRES: OS=macosx
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
import Swift
|
|
import SwiftShims
|
|
|
|
// Test <rdar://59559805> miscompile; use-after-free
|
|
// Avoid hoisting strong_release of an existential
|
|
// over a store to the value.
|
|
protocol ArrayElementProtocol {}
|
|
|
|
struct ArrayElementStruct : ArrayElementProtocol {
|
|
@_hasStorage @_hasInitialValue var dummy: Int { get set }
|
|
}
|
|
|
|
// CHECK-LABEL: sil @testArrayStorageInitAfterFree : $@convention(thin) () -> () {
|
|
// CHECK: [[ARRAY:%.*]] = alloc_ref [stack] [tail_elems $any ArrayElementProtocol * undef : $Builtin.Word] $_ContiguousArrayStorage<any ArrayElementProtocol>
|
|
// CHECK: [[CAST:%.*]] = upcast [[ARRAY]] : $_ContiguousArrayStorage<any ArrayElementProtocol> to $__ContiguousArrayStorageBase
|
|
// CHECK: [[TAIL:%.*]] = ref_tail_addr [[CAST]] : $__ContiguousArrayStorageBase, $any ArrayElementProtocol
|
|
// CHECK: [[ADR:%.*]] = init_existential_addr [[TAIL]] : $*any ArrayElementProtocol, $ArrayElementStruct
|
|
// CHECK: store %{{.*}} to [[ADR]] : $*ArrayElementStruct
|
|
// CHECK: strong_release [[ARRAY]] : $_ContiguousArrayStorage<any ArrayElementProtocol>
|
|
// CHECK-LABEL: } // end sil function 'testArrayStorageInitAfterFree'
|
|
sil @testArrayStorageInitAfterFree : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = alloc_ref [stack] [tail_elems $ArrayElementProtocol * undef : $Builtin.Word] $_ContiguousArrayStorage<ArrayElementProtocol>
|
|
%1 = upcast %0 : $_ContiguousArrayStorage<ArrayElementProtocol> to $__ContiguousArrayStorageBase
|
|
%2 = struct $_SwiftArrayBodyStorage (undef : $Int, undef : $UInt)
|
|
%3 = struct $_ArrayBody (%2 : $_SwiftArrayBodyStorage)
|
|
%4 = ref_element_addr %1 : $__ContiguousArrayStorageBase, #__ContiguousArrayStorageBase.countAndCapacity
|
|
store %3 to %4 : $*_ArrayBody
|
|
%6 = ref_tail_addr %1 : $__ContiguousArrayStorageBase, $ArrayElementProtocol
|
|
%7 = value_to_bridge_object undef : $Builtin.Int64
|
|
%8 = struct $_StringObject (undef : $UInt64, %7 : $Builtin.BridgeObject)
|
|
%9 = struct $_StringGuts (%8 : $_StringObject)
|
|
%10 = struct $String (%9 : $_StringGuts)
|
|
%11 = struct $ArrayElementStruct (undef : $Int)
|
|
%12 = init_existential_addr %6 : $*ArrayElementProtocol, $ArrayElementStruct
|
|
store %11 to %12 : $*ArrayElementStruct
|
|
strong_release %0 : $_ContiguousArrayStorage<ArrayElementProtocol>
|
|
dealloc_stack_ref %0 : $_ContiguousArrayStorage<ArrayElementProtocol>
|
|
%16 = tuple ()
|
|
return %16 : $()
|
|
}
|