Skip to content

Commit 41a6b8e

Browse files
committed
SwiftCompilerSources: move SIL-related Context APIs from Optimizer to the SIL module
1 parent 319f49a commit 41a6b8e

20 files changed

+361
-430
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/AllocBoxToStack.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private func tryConvertBoxesToStack(in function: Function, _ context: FunctionPa
102102
hoistMarkUnresolvedInsts(stackAddress: stack, checkKind: .consumableAndAssignable, context)
103103
}
104104
if !promotableBoxes.isEmpty {
105-
function.fixStackNesting(context)
105+
context.fixStackNesting(in: function)
106106
}
107107

108108
return functionsToSpecialize

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ClosureSpecialization.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ let autodiffClosureSpecialization = FunctionPass(name: "autodiff-closure-special
158158
}
159159

160160
if context.needFixStackNesting {
161-
function.fixStackNesting(context)
161+
context.fixStackNesting(in: function)
162162
}
163163

164164
remainingSpecializationRounds -= 1
@@ -836,7 +836,7 @@ private extension SpecializationCloner {
836836
}
837837

838838
if (self.context.needFixStackNesting) {
839-
self.cloned.fixStackNesting(self.context)
839+
self.context.fixStackNesting(in: self.cloned)
840840
}
841841
}
842842
}

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeEscapeEffects.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ let computeEscapeEffects = FunctionPass(name: "compute-escape-effects") {
7272
return
7373
}
7474

75-
context.modifyEffects(in: function) { (effects: inout FunctionEffects) in
75+
function.modifyEffects(context) { (effects: inout FunctionEffects) in
7676
effects.escapeEffects.arguments = newEffects
7777
}
7878
}

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeSideEffects.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ let computeSideEffects = FunctionPass(name: "compute-side-effects") {
6969
}
7070

7171
// Finally replace the function's side effects.
72-
context.modifyEffects(in: function) { (effects: inout FunctionEffects) in
72+
function.modifyEffects(context) { (effects: inout FunctionEffects) in
7373
let globalEffects = function.isProgramTerminationPoint ?
7474
collectedEffects.globalEffects.forProgramTerminationPoints
7575
: collectedEffects.globalEffects

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/SimplificationPasses.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func runSimplification(on function: Function, _ context: FunctionPassContext,
110110
} while !worklist.isEmpty
111111

112112
if context.needFixStackNesting {
113-
function.fixStackNesting(context)
113+
context.fixStackNesting(in: function)
114114
}
115115

116116
return changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/StackPromotion.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ let stackPromotion = FunctionPass(name: "stack-promotion") {
5757
}
5858
if needFixStackNesting {
5959
// Make sure that all stack allocating instructions are nested correctly.
60-
function.fixStackNesting(context)
60+
context.fixStackNesting(in: function)
6161
}
6262
}
6363

SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyBuiltin.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ extension BuiltinInst : OnoneSimplifiable, SILCombineSimplifiable {
5656
case .Xor:
5757
simplifyNegation(context)
5858
default:
59-
if let literal = constantFold(context) {
59+
if let literal = context.constantFold(builtin: self) {
6060
uses.replaceAll(with: literal, context)
6161
}
6262
}
@@ -240,7 +240,7 @@ private extension BuiltinInst {
240240
if constantFoldStringNullPointerCheck(isEqual: isEqual, context) {
241241
return
242242
}
243-
if let literal = constantFold(context) {
243+
if let literal = context.constantFold(builtin: self) {
244244
uses.replaceAll(with: literal, context)
245245
}
246246
}

SwiftCompilerSources/Sources/Optimizer/ModulePasses/StackProtection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private struct StackProtectionOptimization {
113113
process(instruction: inst, in: function, mustFixStackNesting: &mustFixStackNesting, context)
114114
}
115115
if mustFixStackNesting {
116-
function.fixStackNesting(context)
116+
context.fixStackNesting(in: function)
117117
}
118118
}
119119

0 commit comments

Comments
 (0)