|
72 | 72 | #include "swift/SIL/SILInstruction.h"
|
73 | 73 | #include "swift/SILOptimizer/PassManager/Passes.h"
|
74 | 74 | #include "swift/SILOptimizer/PassManager/Transforms.h"
|
| 75 | +#include "swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h" |
75 | 76 | #include "swift/SILOptimizer/Utils/InstructionDeleter.h"
|
76 | 77 | #include "swift/SILOptimizer/Utils/ParseTestSpecification.h"
|
77 | 78 | #include "llvm/ADT/StringRef.h"
|
@@ -175,6 +176,30 @@ struct TestSpecificationTest : UnitTest {
|
175 | 176 | }
|
176 | 177 | };
|
177 | 178 |
|
| 179 | +// Arguments: |
| 180 | +// - bool: pruneDebug |
| 181 | +// - bool: maximizeLifetimes |
| 182 | +// - SILValue: value to canonicalize |
| 183 | +// Dumps: |
| 184 | +// - function after value canonicalization |
| 185 | +struct CanonicalizeOSSALifetimeTest : UnitTest { |
| 186 | + CanonicalizeOSSALifetimeTest(UnitTestRunner *pass) : UnitTest(pass) {} |
| 187 | + void invoke(Arguments &arguments) override { |
| 188 | + auto *accessBlockAnalysis = getAnalysis<NonLocalAccessBlockAnalysis>(); |
| 189 | + auto *dominanceAnalysis = getAnalysis<DominanceAnalysis>(); |
| 190 | + DominanceInfo *domTree = dominanceAnalysis->get(getFunction()); |
| 191 | + auto pruneDebug = arguments.takeBool(); |
| 192 | + auto maximizeLifetimes = arguments.takeBool(); |
| 193 | + InstructionDeleter deleter; |
| 194 | + CanonicalizeOSSALifetime canonicalizer(pruneDebug, maximizeLifetimes, accessBlockAnalysis, |
| 195 | + domTree, deleter); |
| 196 | + auto value = arguments.takeValue(); |
| 197 | + canonicalizer.canonicalizeValueLifetime(value); |
| 198 | + getFunction()->dump(); |
| 199 | + } |
| 200 | +}; |
| 201 | + |
| 202 | +/// [new_tests] Add the new UnitTest subclass below this line. |
178 | 203 | /// [new_tests] Add the new UnitTest subclass above this line.
|
179 | 204 |
|
180 | 205 | class UnitTestRunner : public SILFunctionTransform {
|
@@ -205,6 +230,8 @@ class UnitTestRunner : public SILFunctionTransform {
|
205 | 230 | }
|
206 | 231 |
|
207 | 232 | ADD_UNIT_TEST_SUBCLASS("test-specification-parsing", TestSpecificationTest)
|
| 233 | + ADD_UNIT_TEST_SUBCLASS("canonicalize-ossa-lifetime", |
| 234 | + CanonicalizeOSSALifetimeTest) |
208 | 235 | /// [new_tests] Add the new mapping from string to subclass above this line.
|
209 | 236 |
|
210 | 237 | #undef ADD_UNIT_TEST_SUBCLASS
|
|
0 commit comments