Skip to content

Commit f996371

Browse files
committed
[Test] Ensourced multidef-liveness.
Moved the test next to the code it calls.
1 parent 303664c commit f996371

File tree

2 files changed

+35
-33
lines changed

2 files changed

+35
-33
lines changed

lib/SIL/Utils/PrunedLiveness.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,41 @@ LiveRangeSummary MultiDefPrunedLiveness::computeSimple() {
679679
return summary;
680680
}
681681

682+
namespace swift::test {
683+
// Arguments:
684+
// - variadic list of live-range defining values or instructions
685+
// Dumps:
686+
// - the liveness result and boundary
687+
//
688+
// Computes liveness for the specified def nodes by finding all their direct SSA
689+
// uses. If the def is an instruction, then all results are considered.
690+
static FunctionTest MultiDefLivenessTest(
691+
"multidef-liveness", [](auto &function, auto &arguments, auto &test) {
692+
SmallVector<SILBasicBlock *, 8> discoveredBlocks;
693+
MultiDefPrunedLiveness liveness(&function, &discoveredBlocks);
694+
695+
llvm::outs() << "MultiDef lifetime analysis:\n";
696+
while (arguments.hasUntaken()) {
697+
auto argument = arguments.takeArgument();
698+
if (isa<InstructionArgument>(argument)) {
699+
auto *instruction = cast<InstructionArgument>(argument).getValue();
700+
llvm::outs() << " def instruction: " << instruction;
701+
liveness.initializeDef(instruction);
702+
} else {
703+
SILValue value = cast<ValueArgument>(argument).getValue();
704+
llvm::outs() << " def value: " << value;
705+
liveness.initializeDef(value);
706+
}
707+
}
708+
liveness.computeSimple();
709+
liveness.print(llvm::outs());
710+
711+
PrunedLivenessBoundary boundary;
712+
liveness.computeBoundary(boundary);
713+
boundary.print(llvm::outs());
714+
});
715+
} // end namespace swift::test
716+
682717
//===----------------------------------------------------------------------===//
683718
// DiagnosticPrunedLiveness
684719
//===----------------------------------------------------------------------===//

lib/SILOptimizer/UtilityPasses/TestRunner.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -230,39 +230,6 @@ static FunctionTest TestSpecificationTest(
230230
// MARK: OSSA Lifetime Unit Tests
231231
//===----------------------------------------------------------------------===//
232232

233-
// Arguments:
234-
// - variadic list of live-range defining values or instructions
235-
// Dumps:
236-
// - the liveness result and boundary
237-
//
238-
// Computes liveness for the specified def nodes by finding all their direct SSA
239-
// uses. If the def is an instruction, then all results are considered.
240-
static FunctionTest MultiDefLivenessTest(
241-
"multidef-liveness", [](auto &function, auto &arguments, auto &test) {
242-
SmallVector<SILBasicBlock *, 8> discoveredBlocks;
243-
MultiDefPrunedLiveness liveness(&function, &discoveredBlocks);
244-
245-
llvm::outs() << "MultiDef lifetime analysis:\n";
246-
while (arguments.hasUntaken()) {
247-
auto argument = arguments.takeArgument();
248-
if (isa<InstructionArgument>(argument)) {
249-
auto *instruction = cast<InstructionArgument>(argument).getValue();
250-
llvm::outs() << " def instruction: " << instruction;
251-
liveness.initializeDef(instruction);
252-
} else {
253-
SILValue value = cast<ValueArgument>(argument).getValue();
254-
llvm::outs() << " def value: " << value;
255-
liveness.initializeDef(value);
256-
}
257-
}
258-
liveness.computeSimple();
259-
liveness.print(llvm::outs());
260-
261-
PrunedLivenessBoundary boundary;
262-
liveness.computeBoundary(boundary);
263-
boundary.print(llvm::outs());
264-
});
265-
266233
// Arguments:
267234
// - the string "defs:"
268235
// - list of live-range defining values or instructions

0 commit comments

Comments
 (0)