Skip to content

Commit 365c1a0

Browse files
committed
[Test] Provide dead-end blocks to SIL tests.
Via a new method on the dependencies struct.
1 parent bb73615 commit 365c1a0

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

include/swift/SIL/Test.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class SILFunctionTransform;
108108
class SILPassManager;
109109
class DominanceAnalysis;
110110
class DominanceInfo;
111+
class DeadEndBlocks;
111112

112113
namespace test {
113114

@@ -162,6 +163,9 @@ class FunctionTest final {
162163
/// Computes and returns the function's dominance tree.
163164
DominanceInfo *getDominanceInfo();
164165

166+
/// The function's dead-end blocks.
167+
DeadEndBlocks *getDeadEndBlocks();
168+
165169
/// Returns the active pass manager.
166170
SILPassManager *getPassManager();
167171

@@ -254,6 +258,7 @@ class FunctionTest final {
254258
/// are visible: TestRunner::FunctionTestDependenciesImpl.
255259
struct Dependencies {
256260
virtual DominanceInfo *getDominanceInfo() = 0;
261+
virtual DeadEndBlocks *getDeadEndBlocks() = 0;
257262
virtual SILPassManager *getPassManager() = 0;
258263
virtual SwiftPassInvocation *getSwiftPassInvocation() = 0;
259264
virtual ~Dependencies(){};

lib/SIL/Utils/Test.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ DominanceInfo *FunctionTest::getDominanceInfo() {
117117
return dependencies->getDominanceInfo();
118118
}
119119

120+
DeadEndBlocks *FunctionTest::getDeadEndBlocks() {
121+
return dependencies->getDeadEndBlocks();
122+
}
123+
120124
SILPassManager *FunctionTest::getPassManager() {
121125
return dependencies->getPassManager();
122126
}

lib/SILOptimizer/UtilityPasses/TestRunner.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "swift/Basic/Assertions.h"
2121
#include "swift/SIL/Test.h"
22+
#include "swift/SILOptimizer/Analysis/DeadEndBlocksAnalysis.h"
2223
#include "swift/SILOptimizer/Analysis/DominanceAnalysis.h"
2324
#include "swift/SILOptimizer/PassManager/Transforms.h"
2425

@@ -43,6 +44,10 @@ class TestRunner : public SILFunctionTransform {
4344
auto *dominanceAnalysis = pass->getAnalysis<DominanceAnalysis>();
4445
return dominanceAnalysis->get(function);
4546
}
47+
DeadEndBlocks *getDeadEndBlocks() override {
48+
auto *deadEndBlocksAnalysis = pass->getAnalysis<DeadEndBlocksAnalysis>();
49+
return deadEndBlocksAnalysis->get(function);
50+
}
4651
SwiftPassInvocation *getSwiftPassInvocation() override {
4752
return &swiftPassInvocation;
4853
}

0 commit comments

Comments
 (0)