Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,26 @@ extension MutatingContext {
func inlineFunction(apply: FullApplySite, mandatoryInline: Bool) {
// This is only a best-effort attempt to notify the new cloned instructions as changed.
// TODO: get a list of cloned instructions from the `inlineFunction`
let instAfterInling: Instruction?
let instBeforeInlining = apply.previous
let instAfterInlining: Instruction?
switch apply {
case is ApplyInst:
instAfterInling = apply.next
instAfterInlining = apply.next
case let beginApply as BeginApplyInst:
let next = beginApply.next!
instAfterInling = (next is EndApplyInst ? nil : next)
instAfterInlining = (next is EndApplyInst ? nil : next)
case is TryApplyInst:
instAfterInling = apply.parentBlock.next?.instructions.first
instAfterInlining = apply.parentBlock.next?.instructions.first
default:
instAfterInling = nil
instAfterInlining = nil
}

bridgedPassContext.inlineFunction(apply.bridged, mandatoryInline)

if let instAfterInling = instAfterInling {
notifyNewInstructions(from: apply, to: instAfterInling)
if let instBeforeInlining = instBeforeInlining?.next,
let instAfterInlining = instAfterInlining,
!instAfterInlining.isDeleted {
notifyNewInstructions(from: instBeforeInlining, to: instAfterInlining)
}
}

Expand Down
24 changes: 24 additions & 0 deletions validation-test/SILOptimizer/rdar161433604.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// RUN: %target-swift-frontend \
// RUN: -disable-availability-checking \
// RUN: -target %target-swift-5.9-abi-triple \
// RUN: -emit-sil -verify \
// RUN: -enable-experimental-feature LifetimeDependence \
// RUN: -enable-experimental-feature Embedded \
// RUN: %s

// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: swift_feature_Embedded
// REQUIRES: swift_feature_LifetimeDependence

struct NoEscapeNoCopy: ~Escapable, ~Copyable {}

protocol Foo {
var bar: NoEscapeNoCopy {get}
}

public struct Baz: Foo {
var bar: NoEscapeNoCopy {
NoEscapeNoCopy() // expected-error{{lifetime-dependent value escapes its scope}}
// expected-note@-1{{it depends on the lifetime of this parent value}}
} // expected-note{{this use causes the lifetime-dependent value to escape}}
}