|
30 | 30 |
|
31 | 31 | #define DEBUG_TYPE "sil-simplify-cfg"
|
32 | 32 |
|
| 33 | +#include "swift/SILOptimizer/Transforms/SimplifyCFG.h" |
33 | 34 | #include "swift/AST/Module.h"
|
34 | 35 | #include "swift/SIL/BasicBlockDatastructures.h"
|
35 | 36 | #include "swift/SIL/DebugUtils.h"
|
|
40 | 41 | #include "swift/SIL/SILModule.h"
|
41 | 42 | #include "swift/SIL/SILUndef.h"
|
42 | 43 | #include "swift/SIL/TerminatorUtils.h"
|
| 44 | +#include "swift/SIL/Test.h" |
43 | 45 | #include "swift/SILOptimizer/Analysis/DeadEndBlocksAnalysis.h"
|
44 | 46 | #include "swift/SILOptimizer/Analysis/DominanceAnalysis.h"
|
45 | 47 | #include "swift/SILOptimizer/Analysis/ProgramTerminationAnalysis.h"
|
46 | 48 | #include "swift/SILOptimizer/Analysis/SimplifyInstruction.h"
|
47 | 49 | #include "swift/SILOptimizer/PassManager/Passes.h"
|
48 | 50 | #include "swift/SILOptimizer/PassManager/Transforms.h"
|
49 |
| -#include "swift/SILOptimizer/Transforms/SimplifyCFG.h" |
50 | 51 | #include "swift/SILOptimizer/Utils/BasicBlockOptUtils.h"
|
51 | 52 | #include "swift/SILOptimizer/Utils/CFGOptUtils.h"
|
52 | 53 | #include "swift/SILOptimizer/Utils/CastOptimizer.h"
|
@@ -3619,6 +3620,26 @@ bool SimplifyCFG::simplifyArgument(SILBasicBlock *BB, unsigned i) {
|
3619 | 3620 | return true;
|
3620 | 3621 | }
|
3621 | 3622 |
|
| 3623 | +namespace swift::test { |
| 3624 | +/// Arguments |
| 3625 | +/// - block - the block whose argument is to be simplified |
| 3626 | +/// - index - the index of the argument to be simplified |
| 3627 | +/// Dumps: |
| 3628 | +/// - nothing |
| 3629 | +static FunctionTest SimplifyCFGSimplifyArgument( |
| 3630 | + "simplify-cfg-simplify-argument", |
| 3631 | + [](auto &function, auto &arguments, auto &test) { |
| 3632 | + auto *passToRun = cast<SILFunctionTransform>(createSimplifyCFG()); |
| 3633 | + passToRun->injectPassManager(test.getPassManager()); |
| 3634 | + passToRun->injectFunction(&function); |
| 3635 | + auto *block = arguments.takeBlock(); |
| 3636 | + auto index = arguments.takeUInt(); |
| 3637 | + SimplifyCFG(function, *passToRun, /*VerifyAll=*/false, |
| 3638 | + /*EnableJumpThread=*/false) |
| 3639 | + .simplifyArgument(block, index); |
| 3640 | + }); |
| 3641 | +} // end namespace swift::test |
| 3642 | + |
3622 | 3643 | // OWNERSHIP NOTE: This is always safe for guaranteed and owned arguments since
|
3623 | 3644 | // in both cases the phi will consume its input.
|
3624 | 3645 | static void tryToReplaceArgWithIncomingValue(SILBasicBlock *BB, unsigned i,
|
|
0 commit comments