Skip to content

Commit

Permalink
Merge pull request #68651 from nate-chandler/test/20230920/1
Browse files Browse the repository at this point in the history
[Test] Added for LexicalDestroyHoisting.
  • Loading branch information
swift-ci committed Sep 20, 2023
2 parents fca24bd + 8de1083 commit a119aaf
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/SILOptimizer/Utils/LexicalDestroyHoisting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
#include "swift/SIL/SILBasicBlock.h"
#include "swift/SIL/SILInstruction.h"
#include "swift/SIL/SILValue.h"
#include "swift/SIL/Test.h"
#include "swift/SILOptimizer/Analysis/BasicCalleeAnalysis.h"
#include "swift/SILOptimizer/Analysis/Reachability.h"
#include "swift/SILOptimizer/Analysis/VisitBarrierAccessScopes.h"
#include "swift/SILOptimizer/PassManager/Transforms.h"
#include "swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h"
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
#include "swift/SILOptimizer/Utils/InstructionDeleter.h"
Expand Down Expand Up @@ -405,3 +407,25 @@ bool swift::hoistDestroysOfOwnedLexicalValue(
calleeAnalysis);
return LexicalDestroyHoisting::run(context);
}

namespace swift::test {
// Arguments:
// - bool: pruneDebug
// - bool: maximizeLifetimes
// - bool: "respectAccessScopes", whether to contract lifetimes to end within
// access scopes which they previously enclosed but can't be hoisted
// before
// - SILValue: value to canonicalize
// Dumps:
// - function after value canonicalization
static FunctionTest LexicalDestroyHoistingTest(
"lexical_destroy_hoisting",
[](auto &function, auto &arguments, auto &test) {
auto *calleeAnalysis = test.template getAnalysis<BasicCalleeAnalysis>();
InstructionDeleter deleter;
auto value = arguments.takeValue();
hoistDestroysOfOwnedLexicalValue(value, *value->getFunction(), deleter,
calleeAnalysis);
function.dump();
});
} // end namespace swift::test

0 comments on commit a119aaf

Please sign in to comment.