Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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