Skip to content

Commit a6082ae

Browse files
committed
Update comments and remove dead functions in DSE
1 parent 15df301 commit a6082ae

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

lib/SILOptimizer/Transforms/DeadStoreElimination.cpp

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ using namespace swift;
8181
/// If a large store is broken down to too many smaller stores, bail out.
8282
/// Currently, we only do partial dead store if we can form a single contiguous
8383
/// 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);
8686

8787
STATISTIC(NumDeadStores, "Number of dead stores removed");
8888
STATISTIC(NumPartialDeadStores, "Number of partial dead stores removed");
@@ -102,6 +102,10 @@ enum class DSEKind : unsigned {
102102
PerformDSE = 2,
103103
};
104104

105+
//===----------------------------------------------------------------------===//
106+
// Utility Functions
107+
//===----------------------------------------------------------------------===//
108+
105109
/// Return the deallocate stack instructions corresponding to the given
106110
/// AllocStackInst.
107111
static llvm::SmallVector<SILInstruction *, 1>
@@ -115,10 +119,6 @@ findDeallocStackInst(AllocStackInst *ASI) {
115119
return DSIs;
116120
}
117121

118-
//===----------------------------------------------------------------------===//
119-
// Utility Functions
120-
//===----------------------------------------------------------------------===//
121-
122122
static inline bool isComputeMaxStoreSet(DSEKind Kind) {
123123
return Kind == DSEKind::ComputeMaxStoreSet;
124124
}
@@ -169,7 +169,6 @@ constexpr unsigned MaxLSLocationBBMultiplicationNone = 256*256;
169169
/// and 64 locations which is a sizeable function.
170170
constexpr unsigned MaxLSLocationBBMultiplicationPessimistic = 64*64;
171171

172-
173172
/// forward declaration.
174173
class DSEContext;
175174
/// BlockState summarizes how LSLocations are used in a basic block.
@@ -193,10 +192,8 @@ class DSEContext;
193192
/// 2. When a load instruction is encountered, remove the loaded location and
194193
/// any location it may alias with from the BBWriteSetMid.
195194
///
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.
200197
class BlockState {
201198
public:
202199
/// The basic block this BlockState represents.
@@ -257,9 +254,6 @@ class BlockState {
257254
init(LocationNum, Optimistic);
258255
}
259256

260-
/// Return the current basic block.
261-
SILBasicBlock *getBB() const { return BB; }
262-
263257
/// Initialize the bitvectors for the current basic block.
264258
void init(unsigned LocationNum, bool Optimistic);
265259

@@ -303,6 +297,8 @@ bool BlockState::isTrackingLocation(llvm::SmallBitVector &BV, unsigned i) {
303297

304298
namespace {
305299

300+
/// The dead store elimination context, keep information about stores in a basic
301+
/// block granularity.
306302
class DSEContext {
307303
/// How to process the current function.
308304
enum class ProcessKind {
@@ -439,22 +435,19 @@ enum class ProcessKind {
439435
AliasAnalysis *AA, EscapeAnalysis *EA, TypeExpansionAnalysis *TE,
440436
llvm::BumpPtrAllocator &BPA,
441437
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) {}
443439

444440
/// Entry point for dead store elimination.
445441
bool run();
446442

447443
/// Run the iterative DF to converge the BBWriteSetIn.
448444
void runIterativeDSE();
449445

450-
/// Returns the escape analysis we use.
451-
EscapeAnalysis *getEA() { return EA; }
452-
453446
/// Returns the location vault of the current function.
454447
std::vector<LSLocation> &getLocationVault() { return LocationVault; }
455448

456449
/// Returns the epilogue release matcher we are using.
457-
ConsumedArgToEpilogueReleaseMatcher &getERM() const { return ERM; };
450+
ConsumedArgToEpilogueReleaseMatcher &getERM() const { return ERM; }
458451

459452
/// Use a set of ad hoc rules to tell whether we should run a pessimistic
460453
/// one iteration data flow on the function.
@@ -688,8 +681,8 @@ void DSEContext::mergeSuccessorLiveIns(SILBasicBlock *BB) {
688681
auto Iter = BB->succ_begin();
689682
C->BBWriteSetOut = getBlockState(*Iter)->BBWriteSetIn;
690683

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.
693686
///
694687
/// To do so, we canonicalize LSLocations, i.e. traced back to the underlying
695688
/// object. Therefore, no need to do a O(N^2) comparison to figure out what is

0 commit comments

Comments
 (0)