Skip to content

Commit ec120e4

Browse files
committed
[Test] Ensourced canonicalize-borrow-scope.
Moved the test next to the code it calls.
1 parent c0783aa commit ec120e4

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

lib/SILOptimizer/UtilityPasses/TestRunner.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -311,22 +311,6 @@ static FunctionTest FieldSensitiveMultiDefUseLiveRangeTest(
311311
boundary.print(llvm::errs());
312312
});
313313

314-
// Arguments:
315-
// - SILValue: value to canonicalize
316-
// Dumps:
317-
// - function after value canonicalization
318-
static FunctionTest CanonicalizeBorrowScopeTest(
319-
"canonicalize-borrow-scope",
320-
[](auto &function, auto &arguments, auto &test) {
321-
auto value = arguments.takeValue();
322-
auto borrowedValue = BorrowedValue(value);
323-
assert(borrowedValue && "specified value isn't a BorrowedValue!?");
324-
InstructionDeleter deleter;
325-
CanonicalizeBorrowScope canonicalizer(value->getFunction(), deleter);
326-
canonicalizer.canonicalizeBorrowScope(borrowedValue);
327-
function.dump();
328-
});
329-
330314
// Arguments:
331315
// - instruction
332316
// Dumps:

lib/SILOptimizer/Utils/CanonicalizeBorrowScope.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "swift/Basic/Defer.h"
2727
#include "swift/SIL/InstructionUtils.h"
2828
#include "swift/SIL/OwnershipUtils.h"
29+
#include "swift/SIL/Test.h"
2930
#include "swift/SILOptimizer/Utils/CFGOptUtils.h"
3031
#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h"
3132
#include "swift/SILOptimizer/Utils/DebugOptUtils.h"
@@ -851,3 +852,21 @@ canonicalizeBorrowScope(BorrowedValue borrowedValue) {
851852

852853
return true;
853854
}
855+
856+
namespace swift::test {
857+
// Arguments:
858+
// - SILValue: value to canonicalize
859+
// Dumps:
860+
// - function after value canonicalization
861+
static FunctionTest CanonicalizeBorrowScopeTest(
862+
"canonicalize-borrow-scope",
863+
[](auto &function, auto &arguments, auto &test) {
864+
auto value = arguments.takeValue();
865+
auto borrowedValue = BorrowedValue(value);
866+
assert(borrowedValue && "specified value isn't a BorrowedValue!?");
867+
InstructionDeleter deleter;
868+
CanonicalizeBorrowScope canonicalizer(value->getFunction(), deleter);
869+
canonicalizer.canonicalizeBorrowScope(borrowedValue);
870+
function.dump();
871+
});
872+
} // end namespace swift::test

0 commit comments

Comments
 (0)