Skip to content

Commit 094b246

Browse files
committed
SIL: FunctionArgument.copyFlags needs a MutatingContext argument
SIL may only be modified through a MutatingContext. Otherwise analysis notifications may get lost.
1 parent d025e9f commit 094b246

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ClosureSpecialization.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ private extension SpecializationCloner {
710710
.forEach { _, arg in
711711
let clonedEntryBlockArgType = arg.type.getLoweredType(in: clonedFunction)
712712
let clonedEntryBlockArg = clonedEntryBlock.addFunctionArgument(type: clonedEntryBlockArgType, self.context)
713-
clonedEntryBlockArg.copyFlags(from: arg as! FunctionArgument)
713+
clonedEntryBlockArg.copyFlags(from: arg as! FunctionArgument, self.context)
714714
}
715715
}
716716

SwiftCompilerSources/Sources/Optimizer/PassManager/Context.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,18 @@ extension Argument {
656656
}
657657
}
658658

659+
extension FunctionArgument {
660+
/// Copies the following flags from `arg`:
661+
/// 1. noImplicitCopy
662+
/// 2. lifetimeAnnotation
663+
/// 3. closureCapture
664+
/// 4. parameterPack
665+
func copyFlags(from arg: FunctionArgument, _ context: some MutatingContext) {
666+
context.notifyInstructionsChanged()
667+
bridged.copyFlags(arg.bridged)
668+
}
669+
}
670+
659671
extension AllocRefInstBase {
660672
func setIsStackAllocatable(_ context: some MutatingContext) {
661673
context.notifyInstructionsChanged()

SwiftCompilerSources/Sources/SIL/Argument.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,6 @@ final public class FunctionArgument : Argument {
8383
public var resultDependence: LifetimeDependenceConvention? {
8484
parentFunction.argumentConventions[resultDependsOn: index]
8585
}
86-
87-
/// Copies the following flags from `arg`:
88-
/// 1. noImplicitCopy
89-
/// 2. lifetimeAnnotation
90-
/// 3. closureCapture
91-
/// 4. parameterPack
92-
public func copyFlags(from arg: FunctionArgument) {
93-
bridged.copyFlags(arg.bridged)
94-
}
9586
}
9687

9788
public struct Phi {

0 commit comments

Comments
 (0)