|
19 | 19 | #include "swift/SIL/SILBasicBlock.h"
|
20 | 20 | #include "swift/SIL/SILInstruction.h"
|
21 | 21 | #include "swift/SIL/SILValue.h"
|
| 22 | +#include "swift/SIL/Test.h" |
22 | 23 | #include "swift/SILOptimizer/Analysis/BasicCalleeAnalysis.h"
|
23 | 24 | #include "swift/SILOptimizer/Analysis/Reachability.h"
|
24 | 25 | #include "swift/SILOptimizer/Analysis/VisitBarrierAccessScopes.h"
|
| 26 | +#include "swift/SILOptimizer/PassManager/Transforms.h" |
25 | 27 | #include "swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h"
|
26 | 28 | #include "swift/SILOptimizer/Utils/InstOptUtils.h"
|
27 | 29 | #include "swift/SILOptimizer/Utils/InstructionDeleter.h"
|
@@ -405,3 +407,25 @@ bool swift::hoistDestroysOfOwnedLexicalValue(
|
405 | 407 | calleeAnalysis);
|
406 | 408 | return LexicalDestroyHoisting::run(context);
|
407 | 409 | }
|
| 410 | + |
| 411 | +namespace swift::test { |
| 412 | +// Arguments: |
| 413 | +// - bool: pruneDebug |
| 414 | +// - bool: maximizeLifetimes |
| 415 | +// - bool: "respectAccessScopes", whether to contract lifetimes to end within |
| 416 | +// access scopes which they previously enclosed but can't be hoisted |
| 417 | +// before |
| 418 | +// - SILValue: value to canonicalize |
| 419 | +// Dumps: |
| 420 | +// - function after value canonicalization |
| 421 | +static FunctionTest LexicalDestroyHoistingTest( |
| 422 | + "lexical_destroy_hoisting", |
| 423 | + [](auto &function, auto &arguments, auto &test) { |
| 424 | + auto *calleeAnalysis = test.template getAnalysis<BasicCalleeAnalysis>(); |
| 425 | + InstructionDeleter deleter; |
| 426 | + auto value = arguments.takeValue(); |
| 427 | + hoistDestroysOfOwnedLexicalValue(value, *value->getFunction(), deleter, |
| 428 | + calleeAnalysis); |
| 429 | + function.dump(); |
| 430 | + }); |
| 431 | +} // end namespace swift::test |
0 commit comments