@@ -81,8 +81,8 @@ using namespace swift;
81
81
// / If a large store is broken down to too many smaller stores, bail out.
82
82
// / Currently, we only do partial dead store if we can form a single contiguous
83
83
// / non-dead store.
84
- static llvm::cl::opt<unsigned > MaxPartialStoreCount ( " max-partial-store-count " ,
85
- llvm::cl::init (1 ), llvm::cl::Hidden);
84
+ static llvm::cl::opt<unsigned >
85
+ MaxPartialStoreCount ( " max-partial-store-count " , llvm::cl::init(1 ), llvm::cl::Hidden);
86
86
87
87
STATISTIC (NumDeadStores, " Number of dead stores removed" );
88
88
STATISTIC (NumPartialDeadStores, " Number of partial dead stores removed" );
@@ -102,6 +102,10 @@ enum class DSEKind : unsigned {
102
102
PerformDSE = 2 ,
103
103
};
104
104
105
+ // ===----------------------------------------------------------------------===//
106
+ // Utility Functions
107
+ // ===----------------------------------------------------------------------===//
108
+
105
109
// / Return the deallocate stack instructions corresponding to the given
106
110
// / AllocStackInst.
107
111
static llvm::SmallVector<SILInstruction *, 1 >
@@ -115,10 +119,6 @@ findDeallocStackInst(AllocStackInst *ASI) {
115
119
return DSIs;
116
120
}
117
121
118
- // ===----------------------------------------------------------------------===//
119
- // Utility Functions
120
- // ===----------------------------------------------------------------------===//
121
-
122
122
static inline bool isComputeMaxStoreSet (DSEKind Kind) {
123
123
return Kind == DSEKind::ComputeMaxStoreSet;
124
124
}
@@ -169,7 +169,6 @@ constexpr unsigned MaxLSLocationBBMultiplicationNone = 256*256;
169
169
// / and 64 locations which is a sizeable function.
170
170
constexpr unsigned MaxLSLocationBBMultiplicationPessimistic = 64 *64 ;
171
171
172
-
173
172
// / forward declaration.
174
173
class DSEContext ;
175
174
// / BlockState summarizes how LSLocations are used in a basic block.
@@ -193,10 +192,8 @@ class DSEContext;
193
192
// / 2. When a load instruction is encountered, remove the loaded location and
194
193
// / any location it may alias with from the BBWriteSetMid.
195
194
// /
196
- // / 3. When an instruction reads from memory in an unknown way, the
197
- // / BBWriteSetMid bit is cleared if the instruction can read the
198
- // / corresponding LSLocation.
199
- // /
195
+ // / 3. When an instruction reads from memory in an unknown way, the BBWriteSet
196
+ // / bit is cleared if the instruction can read the corresponding LSLocation.
200
197
class BlockState {
201
198
public:
202
199
// / The basic block this BlockState represents.
@@ -257,9 +254,6 @@ class BlockState {
257
254
init (LocationNum, Optimistic);
258
255
}
259
256
260
- // / Return the current basic block.
261
- SILBasicBlock *getBB () const { return BB; }
262
-
263
257
// / Initialize the bitvectors for the current basic block.
264
258
void init (unsigned LocationNum, bool Optimistic);
265
259
@@ -303,6 +297,8 @@ bool BlockState::isTrackingLocation(llvm::SmallBitVector &BV, unsigned i) {
303
297
304
298
namespace {
305
299
300
+ // / The dead store elimination context, keep information about stores in a basic
301
+ // / block granularity.
306
302
class DSEContext {
307
303
// / How to process the current function.
308
304
enum class ProcessKind {
@@ -439,22 +435,19 @@ enum class ProcessKind {
439
435
AliasAnalysis *AA, EscapeAnalysis *EA, TypeExpansionAnalysis *TE,
440
436
llvm::BumpPtrAllocator &BPA,
441
437
ConsumedArgToEpilogueReleaseMatcher &ERM)
442
- : Mod(M), F(F), PM(PM), AA(AA), EA(EA), TE(TE), BPA(BPA), ERM(ERM) {}
438
+ : Mod(M), F(F), PM(PM), AA(AA), EA(EA), TE(TE), BPA(BPA), ERM(ERM) {}
443
439
444
440
// / Entry point for dead store elimination.
445
441
bool run ();
446
442
447
443
// / Run the iterative DF to converge the BBWriteSetIn.
448
444
void runIterativeDSE ();
449
445
450
- // / Returns the escape analysis we use.
451
- EscapeAnalysis *getEA () { return EA; }
452
-
453
446
// / Returns the location vault of the current function.
454
447
std::vector<LSLocation> &getLocationVault () { return LocationVault; }
455
448
456
449
// / Returns the epilogue release matcher we are using.
457
- ConsumedArgToEpilogueReleaseMatcher &getERM () const { return ERM; };
450
+ ConsumedArgToEpilogueReleaseMatcher &getERM () const { return ERM; }
458
451
459
452
// / Use a set of ad hoc rules to tell whether we should run a pessimistic
460
453
// / one iteration data flow on the function.
@@ -688,8 +681,8 @@ void DSEContext::mergeSuccessorLiveIns(SILBasicBlock *BB) {
688
681
auto Iter = BB->succ_begin ();
689
682
C->BBWriteSetOut = getBlockState (*Iter)->BBWriteSetIn ;
690
683
691
- // / Merge/intersection is very frequently performed, so it is important to make
692
- // / it as cheap as possible.
684
+ // / Merge/intersection is very frequently performed, so it is important to
685
+ // / make it as cheap as possible.
693
686
// /
694
687
// / To do so, we canonicalize LSLocations, i.e. traced back to the underlying
695
688
// / object. Therefore, no need to do a O(N^2) comparison to figure out what is
0 commit comments