Skip to content

Commit 701a7f7

Browse files
committed
SwiftCompilerSources: don't make anything public in the Optimizer module
The Optimizer module is a leave module. No other modules depend on it. Therefore nothing must be public in this module.
1 parent 44cd8d7 commit 701a7f7

File tree

10 files changed

+46
-48
lines changed

10 files changed

+46
-48
lines changed

SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ private struct FindBeginBorrowWalker : ValueUseDefWalker {
692692
let beginBorrow: BorrowIntroducingInstruction
693693
var walkUpCache = WalkerCache<Path>()
694694

695-
public mutating func walkUp(value: Value, path: SmallProjectionPath) -> WalkResult {
695+
mutating func walkUp(value: Value, path: SmallProjectionPath) -> WalkResult {
696696
if value == beginBorrow {
697697
return .abortWalk
698698
}

SwiftCompilerSources/Sources/Optimizer/Analysis/CalleeAnalysis.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import OptimizerBridging
1414
import SIL
1515

16-
public struct CalleeAnalysis {
16+
struct CalleeAnalysis {
1717
let bridged: BridgedCalleeAnalysis
1818

1919
static func register() {
@@ -31,27 +31,27 @@ public struct CalleeAnalysis {
3131
)
3232
}
3333

34-
public func getCallees(callee: Value) -> FunctionArray? {
34+
func getCallees(callee: Value) -> FunctionArray? {
3535
let bridgedFuncs = bridged.getCallees(callee.bridged)
3636
if bridgedFuncs.isIncomplete() {
3737
return nil
3838
}
3939
return FunctionArray(bridged: bridgedFuncs)
4040
}
4141

42-
public func getIncompleteCallees(callee: Value) -> FunctionArray {
42+
func getIncompleteCallees(callee: Value) -> FunctionArray {
4343
return FunctionArray(bridged: bridged.getCallees(callee.bridged))
4444
}
4545

46-
public func getDestructor(ofExactType type: Type) -> Function? {
46+
func getDestructor(ofExactType type: Type) -> Function? {
4747
let destructors = FunctionArray(bridged: bridged.getDestructors(type.bridged, /*isExactType*/ true))
4848
if destructors.count == 1 {
4949
return destructors[0]
5050
}
5151
return nil
5252
}
5353

54-
public func getDestructors(of type: Type) -> FunctionArray? {
54+
func getDestructors(of type: Type) -> FunctionArray? {
5555
let bridgedDtors = bridged.getDestructors(type.bridged, /*isExactType*/ false)
5656
if bridgedDtors.isIncomplete() {
5757
return nil
@@ -60,11 +60,11 @@ public struct CalleeAnalysis {
6060
}
6161

6262
/// Returns the global (i.e. not argument specific) side effects of an apply.
63-
public func getSideEffects(ofApply apply: FullApplySite) -> SideEffects.GlobalEffects {
63+
func getSideEffects(ofApply apply: FullApplySite) -> SideEffects.GlobalEffects {
6464
return getSideEffects(ofCallee: apply.callee)
6565
}
6666

67-
public func getSideEffects(ofCallee callee: Value) -> SideEffects.GlobalEffects {
67+
func getSideEffects(ofCallee callee: Value) -> SideEffects.GlobalEffects {
6868
guard let callees = getCallees(callee: callee) else {
6969
return .worstEffects
7070
}
@@ -78,7 +78,7 @@ public struct CalleeAnalysis {
7878
}
7979

8080
/// Returns the argument specific side effects of an apply.
81-
public func getSideEffects(of apply: FullApplySite, operand: Operand, path: SmallProjectionPath) -> SideEffects.GlobalEffects {
81+
func getSideEffects(of apply: FullApplySite, operand: Operand, path: SmallProjectionPath) -> SideEffects.GlobalEffects {
8282
var result = SideEffects.GlobalEffects()
8383
guard let calleeArgIdx = apply.calleeArgumentIndex(of: operand) else {
8484
return result
@@ -133,7 +133,7 @@ extension Instruction {
133133
///
134134
/// Deinitialization barriers constrain variable lifetimes. Lexical
135135
/// end_borrow, destroy_value, and destroy_addr cannot be hoisted above them.
136-
public final func isDeinitBarrier(_ analysis: CalleeAnalysis) -> Bool {
136+
final func isDeinitBarrier(_ analysis: CalleeAnalysis) -> Bool {
137137
if let site = self as? FullApplySite {
138138
return site.isBarrier(analysis)
139139
}
@@ -147,19 +147,19 @@ extension Instruction {
147147
}
148148
}
149149

150-
public struct FunctionArray : RandomAccessCollection, FormattedLikeArray {
150+
struct FunctionArray : RandomAccessCollection, FormattedLikeArray {
151151
fileprivate let bridged: BridgedCalleeAnalysis.CalleeList
152152

153-
public var startIndex: Int { 0 }
154-
public var endIndex: Int { bridged.getCount() }
153+
var startIndex: Int { 0 }
154+
var endIndex: Int { bridged.getCount() }
155155

156-
public subscript(_ index: Int) -> Function {
156+
subscript(_ index: Int) -> Function {
157157
return bridged.getCallee(index).function
158158
}
159159
}
160160
// Bridging utilities
161161

162162
extension BridgedCalleeAnalysis {
163-
public var analysis: CalleeAnalysis { .init(bridged: self) }
163+
var analysis: CalleeAnalysis { .init(bridged: self) }
164164
}
165165

SwiftCompilerSources/Sources/Optimizer/Analysis/DeadEndBlocksAnalysis.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
import OptimizerBridging
1414
import SIL
1515

16-
public struct DeadEndBlocksAnalysis {
16+
struct DeadEndBlocksAnalysis {
1717
let bridged: BridgedDeadEndBlocksAnalysis
1818

19-
public func isDeadEnd(_ block: BasicBlock) -> Bool {
19+
func isDeadEnd(_ block: BasicBlock) -> Bool {
2020
return bridged.isDeadEnd(block.bridged)
2121
}
2222
}

SwiftCompilerSources/Sources/Optimizer/Analysis/DominatorTree.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import SIL
1414
import OptimizerBridging
1515

16-
public struct DominatorTree {
16+
struct DominatorTree {
1717
let bridged: BridgedDomTree
1818
}
1919

SwiftCompilerSources/Sources/Optimizer/Analysis/PostDominatorTree.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import SIL
1414
import OptimizerBridging
1515

16-
public struct PostDominatorTree {
16+
struct PostDominatorTree {
1717
let bridged: BridgedPostDomTree
1818
}
1919

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ClosureSpecialization.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,31 +1175,31 @@ private struct OrderedDict<Key: Hashable, Value> {
11751175
private var valueIndexDict: [Key: Int] = [:]
11761176
private var entryList: [(Key, Value)] = []
11771177

1178-
public subscript(key: Key) -> Value? {
1178+
subscript(key: Key) -> Value? {
11791179
if let index = valueIndexDict[key] {
11801180
return entryList[index].1
11811181
}
11821182
return nil
11831183
}
11841184

1185-
public mutating func insert(key: Key, value: Value) {
1185+
mutating func insert(key: Key, value: Value) {
11861186
if valueIndexDict[key] == nil {
11871187
valueIndexDict[key] = entryList.count
11881188
entryList.append((key, value))
11891189
}
11901190
}
11911191

1192-
public mutating func update(key: Key, value: Value) {
1192+
mutating func update(key: Key, value: Value) {
11931193
if let index = valueIndexDict[key] {
11941194
entryList[index].1 = value
11951195
}
11961196
}
11971197

1198-
public var keys: LazyMapSequence<Array<(Key, Value)>, Key> {
1198+
var keys: LazyMapSequence<Array<(Key, Value)>, Key> {
11991199
entryList.lazy.map { $0.0 }
12001200
}
12011201

1202-
public var values: LazyMapSequence<Array<(Key, Value)>, Value> {
1202+
var values: LazyMapSequence<Array<(Key, Value)>, Value> {
12031203
entryList.lazy.map { $0.1 }
12041204
}
12051205
}
@@ -1298,11 +1298,11 @@ private struct CallSite {
12981298
let applySite: ApplySite
12991299
var closureArgDescriptors: [ClosureArgDescriptor] = []
13001300

1301-
public init(applySite: ApplySite) {
1301+
init(applySite: ApplySite) {
13021302
self.applySite = applySite
13031303
}
13041304

1305-
public mutating func appendClosureArgDescriptor(_ descriptor: ClosureArgDescriptor) {
1305+
mutating func appendClosureArgDescriptor(_ descriptor: ClosureArgDescriptor) {
13061306
self.closureArgDescriptors.append(descriptor)
13071307
}
13081308

SwiftCompilerSources/Sources/Optimizer/PassManager/ModulePassContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import OptimizerBridging
2121
struct ModulePassContext : Context, CustomStringConvertible {
2222
let _bridged: BridgedPassContext
2323

24-
public var description: String {
24+
var description: String {
2525
return String(taking: _bridged.getModuleDescription())
2626
}
2727

SwiftCompilerSources/Sources/Optimizer/PassManager/Passes.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ struct FunctionPass {
1717
let name: String
1818
let runFunction: (Function, FunctionPassContext) -> ()
1919

20-
public init(name: String,
21-
_ runFunction: @escaping (Function, FunctionPassContext) -> ()) {
20+
init(name: String, _ runFunction: @escaping (Function, FunctionPassContext) -> ()) {
2221
self.name = name
2322
self.runFunction = runFunction
2423
}
@@ -35,8 +34,7 @@ struct ModulePass {
3534
let name: String
3635
let runFunction: (ModulePassContext) -> ()
3736

38-
public init(name: String,
39-
_ runFunction: @escaping (ModulePassContext) -> ()) {
37+
init(name: String, _ runFunction: @escaping (ModulePassContext) -> ()) {
4038
self.name = name
4139
self.runFunction = runFunction
4240
}

SwiftCompilerSources/Sources/Optimizer/Utilities/DiagnosticEngine.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,38 @@ import ASTBridging
1515
import Basic
1616
import SIL
1717

18-
public typealias DiagID = BridgedDiagID
18+
typealias DiagID = BridgedDiagID
1919

20-
public protocol DiagnosticArgument {
20+
protocol DiagnosticArgument {
2121
func _withBridgedDiagnosticArgument(_ fn: (BridgedDiagnosticArgument) -> Void)
2222
}
2323
extension String: DiagnosticArgument {
24-
public func _withBridgedDiagnosticArgument(_ fn: (BridgedDiagnosticArgument) -> Void) {
24+
func _withBridgedDiagnosticArgument(_ fn: (BridgedDiagnosticArgument) -> Void) {
2525
_withBridgedStringRef { fn(BridgedDiagnosticArgument($0)) }
2626
}
2727
}
2828
extension Int: DiagnosticArgument {
29-
public func _withBridgedDiagnosticArgument(_ fn: (BridgedDiagnosticArgument) -> Void) {
29+
func _withBridgedDiagnosticArgument(_ fn: (BridgedDiagnosticArgument) -> Void) {
3030
fn(BridgedDiagnosticArgument(self))
3131
}
3232
}
3333
extension Type: DiagnosticArgument {
34-
public func _withBridgedDiagnosticArgument(_ fn: (BridgedDiagnosticArgument) -> Void) {
34+
func _withBridgedDiagnosticArgument(_ fn: (BridgedDiagnosticArgument) -> Void) {
3535
fn(bridged.asDiagnosticArgument())
3636
}
3737
}
3838
extension DeclRef: DiagnosticArgument {
39-
public func _withBridgedDiagnosticArgument(_ fn: (BridgedDiagnosticArgument) -> Void) {
39+
func _withBridgedDiagnosticArgument(_ fn: (BridgedDiagnosticArgument) -> Void) {
4040
fn(bridged.asDiagnosticArgument())
4141
}
4242
}
4343

44-
public struct DiagnosticFixIt {
45-
public let start: SourceLoc
46-
public let byteLength: Int
47-
public let text: String
44+
struct DiagnosticFixIt {
45+
let start: SourceLoc
46+
let byteLength: Int
47+
let text: String
4848

49-
public init(start: SourceLoc, byteLength: Int, replacement text: String) {
49+
init(start: SourceLoc, byteLength: Int, replacement text: String) {
5050
self.start = start
5151
self.byteLength = byteLength
5252
self.text = text
@@ -62,20 +62,20 @@ public struct DiagnosticFixIt {
6262
}
6363
}
6464

65-
public struct DiagnosticEngine {
65+
struct DiagnosticEngine {
6666
private let bridged: BridgedDiagnosticEngine
6767

68-
public init(bridged: BridgedDiagnosticEngine) {
68+
init(bridged: BridgedDiagnosticEngine) {
6969
self.bridged = bridged
7070
}
71-
public init?(bridged: BridgedNullableDiagnosticEngine) {
71+
init?(bridged: BridgedNullableDiagnosticEngine) {
7272
guard let raw = bridged.raw else {
7373
return nil
7474
}
7575
self.bridged = BridgedDiagnosticEngine(raw: raw)
7676
}
7777

78-
public func diagnose(_ position: SourceLoc?,
78+
func diagnose(_ position: SourceLoc?,
7979
_ id: DiagID,
8080
_ args: [DiagnosticArgument],
8181
highlight: CharSourceRange? = nil,
@@ -131,7 +131,7 @@ public struct DiagnosticEngine {
131131
closure()
132132
}
133133

134-
public func diagnose(_ position: SourceLoc?,
134+
func diagnose(_ position: SourceLoc?,
135135
_ id: DiagID,
136136
_ args: DiagnosticArgument...,
137137
highlight: CharSourceRange? = nil,

SwiftCompilerSources/Sources/Optimizer/Utilities/LocalVariableUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ struct LocalVariableAccessMap: Collection, CustomStringConvertible {
301301

302302
subscript(instruction: Instruction) -> LocalVariableAccessInfo? { accessMap[instruction] }
303303

304-
public var description: String {
304+
var description: String {
305305
"Access map:\n" + map({String(describing: $0)}).joined(separator: "\n")
306306
}
307307
}

0 commit comments

Comments
 (0)