Skip to content

Commit 5945606

Browse files
Merge pull request #84577 from nate-chandler/rdar161433604
[Optimizer] Use valid inst range to broadcast inlining changes.
2 parents 7609c22 + 07d7518 commit 5945606

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

SwiftCompilerSources/Sources/Optimizer/PassManager/ContextCommon.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,26 @@ extension MutatingContext {
9696
func inlineFunction(apply: FullApplySite, mandatoryInline: Bool) {
9797
// This is only a best-effort attempt to notify the new cloned instructions as changed.
9898
// TODO: get a list of cloned instructions from the `inlineFunction`
99-
let instAfterInling: Instruction?
99+
let instBeforeInlining = apply.previous
100+
let instAfterInlining: Instruction?
100101
switch apply {
101102
case is ApplyInst:
102-
instAfterInling = apply.next
103+
instAfterInlining = apply.next
103104
case let beginApply as BeginApplyInst:
104105
let next = beginApply.next!
105-
instAfterInling = (next is EndApplyInst ? nil : next)
106+
instAfterInlining = (next is EndApplyInst ? nil : next)
106107
case is TryApplyInst:
107-
instAfterInling = apply.parentBlock.next?.instructions.first
108+
instAfterInlining = apply.parentBlock.next?.instructions.first
108109
default:
109-
instAfterInling = nil
110+
instAfterInlining = nil
110111
}
111112

112113
bridgedPassContext.inlineFunction(apply.bridged, mandatoryInline)
113114

114-
if let instAfterInling = instAfterInling {
115-
notifyNewInstructions(from: apply, to: instAfterInling)
115+
if let instBeforeInlining = instBeforeInlining?.next,
116+
let instAfterInlining = instAfterInlining,
117+
!instAfterInlining.isDeleted {
118+
notifyNewInstructions(from: instBeforeInlining, to: instAfterInlining)
116119
}
117120
}
118121

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %target-swift-frontend \
2+
// RUN: -disable-availability-checking \
3+
// RUN: -target %target-swift-5.9-abi-triple \
4+
// RUN: -emit-sil -verify \
5+
// RUN: -enable-experimental-feature LifetimeDependence \
6+
// RUN: -enable-experimental-feature Embedded \
7+
// RUN: %s
8+
9+
// REQUIRES: OS=macosx || OS=linux-gnu
10+
// REQUIRES: swift_feature_Embedded
11+
// REQUIRES: swift_feature_LifetimeDependence
12+
13+
struct NoEscapeNoCopy: ~Escapable, ~Copyable {}
14+
15+
protocol Foo {
16+
var bar: NoEscapeNoCopy {get}
17+
}
18+
19+
public struct Baz: Foo {
20+
var bar: NoEscapeNoCopy {
21+
NoEscapeNoCopy() // expected-error{{lifetime-dependent value escapes its scope}}
22+
// expected-note@-1{{it depends on the lifetime of this parent value}}
23+
} // expected-note{{this use causes the lifetime-dependent value to escape}}
24+
}

0 commit comments

Comments
 (0)