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.
55 lines
1.6 KiB
Swift
55 lines
1.6 KiB
Swift
// RUN: %target-swift-frontend -O %s -parse-as-library -Xllvm -sil-print-types -emit-sil -enforce-exclusivity=none -Xllvm -sil-disable-pass=function-signature-opts | %FileCheck %s
|
|
|
|
// REQUIRES: swift_in_compiler
|
|
|
|
// Test ARC optimizations on source level tests that have been
|
|
// miscompiled and crash (e.g. because of use-after-free).
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// rdar://74469299 (ARC miscompile: EscapeAnalysis::mayReleaseContent;
|
|
// potential use-after-free)
|
|
// -----------------------------------------------------------------------------
|
|
|
|
public class Base {
|
|
var i = 3
|
|
init() {}
|
|
}
|
|
public class Node : Base {
|
|
var node: Base
|
|
|
|
@inline(never)
|
|
init(node: Base) { self.node = node }
|
|
}
|
|
struct Queue {
|
|
var node: Node
|
|
}
|
|
|
|
@inline(never)
|
|
func useQueue(q: __owned Queue) {}
|
|
|
|
@inline(never)
|
|
func useNode(n: Base) -> Int {
|
|
return n.i
|
|
}
|
|
|
|
// CHECK-LABEL: sil [noinline] @$s9arc_crash14testMayReleaseAA4BaseCyF : $@convention(thin) () -> @owned Base {
|
|
// CHECK: [[BASE:%.*]] = alloc_ref $Base
|
|
// CHECK: [[EI:%.*]] = end_init_let_ref [[BASE]]
|
|
// CHECK: strong_retain [[EI]] : $Base
|
|
// CHECK: apply %{{.*}} : $@convention(thin) (@owned Queue) -> ()
|
|
// CHECK-LABEL: } // end sil function '$s9arc_crash14testMayReleaseAA4BaseCyF'
|
|
@inline(never)
|
|
public func testMayRelease() -> Base {
|
|
let n2 = Base()
|
|
let n1 = Node(node: n2)
|
|
let q = Queue(node: n1)
|
|
// n2 must not be release before useQueue.
|
|
useQueue(q: q)
|
|
return n2
|
|
}
|
|
|
|
// This crashes when testMayRelease releases the object too early.
|
|
// print("Object:")
|
|
// print(testMayRelease())
|
|
// -----------------------------------------------------------------------------
|