Skip to content

Commit d8a8569

Browse files
committed
Optimizer: convert the FunctionUsesDumper pass to a test
1 parent 6ef1064 commit d8a8569

File tree

7 files changed

+23
-32
lines changed

7 files changed

+23
-32
lines changed

SwiftCompilerSources/Sources/Optimizer/DataStructures/FunctionUses.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,22 @@ struct FunctionUses {
162162
uses[function, default: FirstUse(of: function)].hasUnknownUses = true
163163
}
164164
}
165+
166+
//===--------------------------------------------------------------------===//
167+
// Tests
168+
//===--------------------------------------------------------------------===//
169+
170+
let functionUsesTest = ModuleTest("function-uses") {
171+
(context: ModulePassContext) in
172+
173+
var functionUses = FunctionUses()
174+
functionUses.collect(context: context)
175+
176+
for function in context.functions {
177+
let uses = functionUses.getUses(of: function)
178+
179+
print("Uses of \(function.name)")
180+
print(uses)
181+
print("End function \(function.name)\n")
182+
}
183+
}

SwiftCompilerSources/Sources/Optimizer/PassManager/PassRegistration.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ private func registerSwiftPasses() {
148148
registerForSILCombine(EndCOWMutationAddrInst.self, { run(EndCOWMutationAddrInst.self, $0) })
149149

150150
// Test passes
151-
registerPass(functionUsesDumper, { functionUsesDumper.run($0) })
152151
registerPass(silPrinterPass, { silPrinterPass.run($0) })
153152
registerPass(rangeDumper, { rangeDumper.run($0) })
154153
registerPass(testInstructionIteration, { testInstructionIteration.run($0) })

SwiftCompilerSources/Sources/Optimizer/TestPasses/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

99
swift_compiler_sources(Optimizer
10-
FunctionUsesDumper.swift
1110
SILPrinter.swift
1211
RangeDumper.swift
1312
UpdateBorrowedFrom.swift

SwiftCompilerSources/Sources/Optimizer/TestPasses/FunctionUsesDumper.swift

Lines changed: 0 additions & 28 deletions
This file was deleted.

SwiftCompilerSources/Sources/Optimizer/Utilities/FunctionTest.swift renamed to SwiftCompilerSources/Sources/Optimizer/Utilities/Test.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public func registerOptimizerTests() {
7171
memoryEffectsTest
7272
)
7373

74+
registerModuleTest(functionUsesTest, { functionUsesTest.pass.run($0) })
75+
7476
// Finally register the thunk they all call through.
7577
registerFunctionTestThunk(functionTestThunk)
7678
}

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ MODULE_PASS(MandatoryAllocBoxToStack, "mandatory-allocbox-to-stack",
158158
"Mandatory stack promotion of box objects")
159159
MODULE_PASS(AsyncDemotion, "async-demotion",
160160
"Convert async functions to be synchronous")
161-
MODULE_PASS(FunctionUsesDumper, "dump-function-uses",
161+
MODULE_PASS(FunctionUsesTestPass, "test-function-uses",
162162
"Dump the results of FunctionUses")
163163
MODULE_PASS(MandatoryPerformanceOptimizations, "mandatory-performance-optimizations",
164164
"Performs optimizations for performance-annotated functions")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-sil-opt -wmo -dump-function-uses %s -o /dev/null | %FileCheck %s
1+
// RUN: %target-sil-opt -wmo -test-function-uses %s -o /dev/null | %FileCheck %s
22

33
// REQUIRES: swift_in_compiler
44

0 commit comments

Comments
 (0)