Files
swift-mirror/validation-test/SILOptimizer/rdar151568816.swift
Meghana Gupta 8396a6d8c0 Fix an inliner crash when inlining begin_apply with scoped lifetime dependence
LifetimeDependenceInsertion inserts mark_dependence on token result of a begin_apply
when it yields a lifetime dependent value. When such a begin_apply gets inlined,
the inliner can crash because of the remaining uses of the token result.

Fix this by inserting mark_dependence on parameter operands that are lifetime dependence sources
and deleting the mark_dependence on token results in the inliner.

Fixes rdar://151568816
2025-06-12 01:35:36 -07:00

33 lines
522 B
Swift

// RUN: %target-swift-frontend %s -enable-experimental-feature Lifetimes -emit-sil
// REQUIRES: swift_in_compiler
// REQUIRES: swift_feature_Lifetimes
// Ensure we don't crash
struct Wrapper : ~Copyable {
}
struct NE : ~Escapable {
@_lifetime(borrow w)
init(_ w: borrowing Wrapper) {}
}
struct MyBox : ~Copyable {
public var value: NE {
_read {
let w = Wrapper()
yield NE(w)
}
}
}
func use(_ n: borrowing NE) {}
func foo() {
let box = MyBox()
let value = box.value
use(value)
}