Skip to content

Commit ef02dc2

Browse files
committed
[Test] Ensourced ssa-liveness.
Moved the test next to the code it calls.
1 parent 524c676 commit ef02dc2

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

lib/SIL/Utils/PrunedLiveness.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,38 @@ LiveRangeSummary PrunedLiveRange<LivenessWithDefs>::recursivelyUpdateForDef(
341341
return summary;
342342
}
343343

344+
namespace swift::test {
345+
// Arguments:
346+
// - SILValue: value to a analyze
347+
// Dumps:
348+
// - the liveness result and boundary
349+
static FunctionTest SSALivenessTest("ssa-liveness", [](auto &function,
350+
auto &arguments,
351+
auto &test) {
352+
auto value = arguments.takeValue();
353+
assert(!arguments.hasUntaken());
354+
llvm::outs() << "SSA lifetime analysis: " << value;
355+
356+
SmallVector<SILBasicBlock *, 8> discoveredBlocks;
357+
SSAPrunedLiveness liveness(value->getFunction(), &discoveredBlocks);
358+
liveness.initializeDef(value);
359+
LiveRangeSummary summary = liveness.computeSimple();
360+
if (summary.innerBorrowKind == InnerBorrowKind::Reborrowed)
361+
llvm::outs() << "Incomplete liveness: Reborrowed inner scope\n";
362+
363+
if (summary.addressUseKind == AddressUseKind::PointerEscape)
364+
llvm::outs() << "Incomplete liveness: Escaping address\n";
365+
else if (summary.addressUseKind == AddressUseKind::Unknown)
366+
llvm::outs() << "Incomplete liveness: Unknown address use\n";
367+
368+
liveness.print(llvm::outs());
369+
370+
PrunedLivenessBoundary boundary;
371+
liveness.computeBoundary(boundary);
372+
boundary.print(llvm::outs());
373+
});
374+
} // end namespace swift::test
375+
344376
template <typename LivenessWithDefs>
345377
bool PrunedLiveRange<LivenessWithDefs>::isWithinBoundary(
346378
SILInstruction *inst) const {

lib/SILOptimizer/UtilityPasses/TestRunner.cpp

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

233-
// Arguments:
234-
// - SILValue: value to a analyze
235-
// Dumps:
236-
// - the liveness result and boundary
237-
static FunctionTest SSALivenessTest("ssa-liveness", [](auto &function,
238-
auto &arguments,
239-
auto &test) {
240-
auto value = arguments.takeValue();
241-
assert(!arguments.hasUntaken());
242-
llvm::outs() << "SSA lifetime analysis: " << value;
243-
244-
SmallVector<SILBasicBlock *, 8> discoveredBlocks;
245-
SSAPrunedLiveness liveness(value->getFunction(), &discoveredBlocks);
246-
liveness.initializeDef(value);
247-
LiveRangeSummary summary = liveness.computeSimple();
248-
if (summary.innerBorrowKind == InnerBorrowKind::Reborrowed)
249-
llvm::outs() << "Incomplete liveness: Reborrowed inner scope\n";
250-
251-
if (summary.addressUseKind == AddressUseKind::PointerEscape)
252-
llvm::outs() << "Incomplete liveness: Escaping address\n";
253-
else if (summary.addressUseKind == AddressUseKind::Unknown)
254-
llvm::outs() << "Incomplete liveness: Unknown address use\n";
255-
256-
liveness.print(llvm::outs());
257-
258-
PrunedLivenessBoundary boundary;
259-
liveness.computeBoundary(boundary);
260-
boundary.print(llvm::outs());
261-
});
262-
263233
// Arguments:
264234
// - SILValue: value to a analyze
265235
// Dumps:

0 commit comments

Comments
 (0)