|
70 | 70 | #include "swift/SIL/NodeDatastructures.h"
|
71 | 71 | #include "swift/SIL/OwnershipUtils.h"
|
72 | 72 | #include "swift/SIL/PrunedLiveness.h"
|
| 73 | +#include "swift/SIL/Test.h" |
73 | 74 | #include "swift/SILOptimizer/Analysis/BasicCalleeAnalysis.h"
|
74 | 75 | #include "swift/SILOptimizer/Analysis/Reachability.h"
|
| 76 | +#include "swift/SILOptimizer/PassManager/Transforms.h" |
75 | 77 | #include "swift/SILOptimizer/Utils/CFGOptUtils.h"
|
76 | 78 | #include "swift/SILOptimizer/Utils/DebugOptUtils.h"
|
77 | 79 | #include "swift/SILOptimizer/Utils/InstructionDeleter.h"
|
@@ -1175,6 +1177,38 @@ bool CanonicalizeOSSALifetime::canonicalizeValueLifetime(SILValue def) {
|
1175 | 1177 | return true;
|
1176 | 1178 | }
|
1177 | 1179 |
|
| 1180 | +namespace swift::test { |
| 1181 | +// Arguments: |
| 1182 | +// - bool: pruneDebug |
| 1183 | +// - bool: maximizeLifetimes |
| 1184 | +// - bool: "respectAccessScopes", whether to contract lifetimes to end within |
| 1185 | +// access scopes which they previously enclosed but can't be hoisted |
| 1186 | +// before |
| 1187 | +// - SILValue: value to canonicalize |
| 1188 | +// Dumps: |
| 1189 | +// - function after value canonicalization |
| 1190 | +static FunctionTest CanonicalizeOSSALifetimeTest( |
| 1191 | + "canonicalize-ossa-lifetime", |
| 1192 | + [](auto &function, auto &arguments, auto &test) { |
| 1193 | + auto *accessBlockAnalysis = |
| 1194 | + test.template getAnalysis<NonLocalAccessBlockAnalysis>(); |
| 1195 | + auto *dominanceAnalysis = test.template getAnalysis<DominanceAnalysis>(); |
| 1196 | + DominanceInfo *domTree = dominanceAnalysis->get(&function); |
| 1197 | + auto *calleeAnalysis = test.template getAnalysis<BasicCalleeAnalysis>(); |
| 1198 | + auto pruneDebug = arguments.takeBool(); |
| 1199 | + auto maximizeLifetimes = arguments.takeBool(); |
| 1200 | + auto respectAccessScopes = arguments.takeBool(); |
| 1201 | + InstructionDeleter deleter; |
| 1202 | + CanonicalizeOSSALifetime canonicalizer( |
| 1203 | + pruneDebug, maximizeLifetimes, &function, |
| 1204 | + respectAccessScopes ? accessBlockAnalysis : nullptr, domTree, |
| 1205 | + calleeAnalysis, deleter); |
| 1206 | + auto value = arguments.takeValue(); |
| 1207 | + canonicalizer.canonicalizeValueLifetime(value); |
| 1208 | + function.dump(); |
| 1209 | + }); |
| 1210 | +} // end namespace swift::test |
| 1211 | + |
1178 | 1212 | //===----------------------------------------------------------------------===//
|
1179 | 1213 | // MARK: Debugging
|
1180 | 1214 | //===----------------------------------------------------------------------===//
|
|
0 commit comments