23
23
#include " swift/SIL/SILFunction.h"
24
24
#include " swift/SIL/SILUndef.h"
25
25
#include " swift/SILOptimizer/Analysis/DominanceAnalysis.h"
26
+ #include " swift/SILOptimizer/Analysis/DeadEndBlocksAnalysis.h"
26
27
#include " swift/SILOptimizer/PassManager/Passes.h"
27
28
#include " swift/SILOptimizer/PassManager/Transforms.h"
28
29
#include " swift/SILOptimizer/Utils/BasicBlockOptUtils.h"
@@ -126,6 +127,8 @@ class DCE {
126
127
BasicBlockSet LiveBlocks;
127
128
llvm::SmallVector<SILInstruction *, 64 > Worklist;
128
129
PostDominanceInfo *PDT;
130
+ DominanceInfo *DT;
131
+ DeadEndBlocks *deadEndBlocks;
129
132
llvm::DenseMap<SILBasicBlock *, ControllingInfo> ControllingInfoMap;
130
133
131
134
// Maps instructions which produce a failing condition (like overflow
@@ -194,8 +197,10 @@ class DCE {
194
197
void endLifetimeOfLiveValue (Operand *op, SILInstruction *insertPt);
195
198
196
199
public:
197
- DCE (SILFunction *F, PostDominanceInfo *PDT)
198
- : F(F), LiveArguments(F), LiveInstructions(F), LiveBlocks(F), PDT(PDT) {}
200
+ DCE (SILFunction *F, PostDominanceInfo *PDT, DominanceInfo *DT,
201
+ DeadEndBlocks *deadEndBlocks)
202
+ : F(F), LiveArguments(F), LiveInstructions(F), LiveBlocks(F), PDT(PDT),
203
+ DT (DT), deadEndBlocks(deadEndBlocks) {}
199
204
200
205
// / The entry point to the transformation.
201
206
bool run () {
@@ -977,8 +982,11 @@ class DCEPass : public SILFunctionTransform {
977
982
LLVM_DEBUG (llvm::dbgs () << " *** DCE on function: " << F->getName ()
978
983
<< " ***\n " );
979
984
980
- auto *DA = PM->getAnalysis <PostDominanceAnalysis>();
981
- PostDominanceInfo *PDT = DA->get (F);
985
+ auto *PDA = PM->getAnalysis <PostDominanceAnalysis>();
986
+ PostDominanceInfo *PDT = PDA->get (F);
987
+
988
+ auto *DA = PM->getAnalysis <DominanceAnalysis>();
989
+ auto *DEA = getAnalysis<DeadEndBlocksAnalysis>();
982
990
983
991
// If we have a function that consists of nothing but a
984
992
// structurally infinite loop like:
@@ -987,7 +995,7 @@ class DCEPass : public SILFunctionTransform {
987
995
if (!PDT->getRootNode ())
988
996
return ;
989
997
990
- DCE dce (F, PDT);
998
+ DCE dce (F, PDT, DA-> get (F), DEA-> get (F) );
991
999
if (dce.run ()) {
992
1000
using InvalidationKind = SILAnalysis::InvalidationKind;
993
1001
unsigned Inv = InvalidationKind::Instructions;
0 commit comments