Skip to content

Commit b0affc4

Browse files
committed
Add unit test runner for OSSSLifetimeCompletion
1 parent 32baaf7 commit b0affc4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/SILOptimizer/UtilityPasses/UnitTestRunner.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include "swift/AST/Type.h"
7070
#include "swift/Basic/TaggedUnion.h"
7171
#include "swift/SIL/MemAccessUtils.h"
72+
#include "swift/SIL/OSSALifetimeCompletion.h"
7273
#include "swift/SIL/OwnershipLiveness.h"
7374
#include "swift/SIL/PrunedLiveness.h"
7475
#include "swift/SIL/SILArgumentArrayRef.h"
@@ -602,6 +603,21 @@ struct ExtendedLinearLivenessTest : UnitTest {
602603
}
603604
};
604605

606+
// Arguments:
607+
// - SILValue: value
608+
// Dumps:
609+
// - function
610+
struct OSSALifetimeCompletionTest : UnitTest {
611+
OSSALifetimeCompletionTest(UnitTestRunner *pass) : UnitTest(pass) {}
612+
void invoke(Arguments &arguments) override {
613+
SILValue value = arguments.takeValue();
614+
llvm::dbgs() << "OSSA lifetime completion: " << value;
615+
OSSALifetimeCompletion completion(getFunction(), /*domInfo*/nullptr);
616+
completion.completeOSSALifetime(value);
617+
getFunction()->dump();
618+
}
619+
};
620+
605621
//===----------------------------------------------------------------------===//
606622
// MARK: SimplifyCFG Unit Tests
607623
//===----------------------------------------------------------------------===//
@@ -778,6 +794,7 @@ void UnitTestRunner::withTest(StringRef name, Doit doit) {
778794
ADD_UNIT_TEST_SUBCLASS("is-lexical", IsLexicalTest)
779795
ADD_UNIT_TEST_SUBCLASS("linear-liveness", LinearLivenessTest)
780796
ADD_UNIT_TEST_SUBCLASS("multidef-liveness", MultiDefLivenessTest)
797+
ADD_UNIT_TEST_SUBCLASS("ossa-lifetime-completion", OSSALifetimeCompletionTest)
781798
ADD_UNIT_TEST_SUBCLASS("pruned-liveness-boundary-with-list-of-last-users-insertion-points", PrunedLivenessBoundaryWithListOfLastUsersInsertionPointsTest)
782799
ADD_UNIT_TEST_SUBCLASS("shrink-borrow-scope", ShrinkBorrowScopeTest)
783800

0 commit comments

Comments
 (0)