Skip to content

Commit 303664c

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

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

lib/SIL/Utils/ScopedAddressUtils.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "swift/SIL/SILArgument.h"
1717
#include "swift/SIL/SILBuilder.h"
1818
#include "swift/SIL/SILInstruction.h"
19+
#include "swift/SIL/Test.h"
1920
#include "swift/SILOptimizer/Utils/InstructionDeleter.h"
2021
#include "swift/SILOptimizer/Utils/OwnershipOptUtils.h"
2122

@@ -105,6 +106,31 @@ AddressUseKind ScopedAddressValue::computeTransitiveLiveness(
105106
return updateTransitiveLiveness(liveness);
106107
}
107108

109+
namespace swift::test {
110+
// Arguments:
111+
// - SILValue: value to a analyze
112+
// Dumps:
113+
// - the liveness result and boundary
114+
static FunctionTest ScopedAddressLivenessTest(
115+
"scoped-address-liveness", [](auto &function, auto &arguments, auto &test) {
116+
auto value = arguments.takeValue();
117+
assert(!arguments.hasUntaken());
118+
llvm::outs() << "Scoped address analysis: " << value;
119+
120+
ScopedAddressValue scopedAddress(value);
121+
assert(scopedAddress);
122+
123+
SmallVector<SILBasicBlock *, 8> discoveredBlocks;
124+
SSAPrunedLiveness liveness(value->getFunction(), &discoveredBlocks);
125+
scopedAddress.computeTransitiveLiveness(liveness);
126+
liveness.print(llvm::outs());
127+
128+
PrunedLivenessBoundary boundary;
129+
liveness.computeBoundary(boundary);
130+
boundary.print(llvm::outs());
131+
});
132+
} // end namespace swift::test
133+
108134
AddressUseKind ScopedAddressValue::updateTransitiveLiveness(
109135
SSAPrunedLiveness &liveness) const {
110136
SmallVector<Operand *, 4> uses;

lib/SILOptimizer/UtilityPasses/TestRunner.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -230,29 +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 ScopedAddressLivenessTest(
238-
"scoped-address-liveness", [](auto &function, auto &arguments, auto &test) {
239-
auto value = arguments.takeValue();
240-
assert(!arguments.hasUntaken());
241-
llvm::outs() << "Scoped address analysis: " << value;
242-
243-
ScopedAddressValue scopedAddress(value);
244-
assert(scopedAddress);
245-
246-
SmallVector<SILBasicBlock *, 8> discoveredBlocks;
247-
SSAPrunedLiveness liveness(value->getFunction(), &discoveredBlocks);
248-
scopedAddress.computeTransitiveLiveness(liveness);
249-
liveness.print(llvm::outs());
250-
251-
PrunedLivenessBoundary boundary;
252-
liveness.computeBoundary(boundary);
253-
boundary.print(llvm::outs());
254-
});
255-
256233
// Arguments:
257234
// - variadic list of live-range defining values or instructions
258235
// Dumps:

0 commit comments

Comments
 (0)