Skip to content

Commit d81df69

Browse files
committed
[RLE-DSE]. Add some comments about memory location canonicalization in DSE. NFC
1 parent 29d6170 commit d81df69

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/SILPasses/Scalar/DeadStoreElimination.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,17 @@ bool BBState::isTrackingMemLocation(unsigned bit) {
242242

243243
void BBState::initialize(const BBState &Succ) { WriteSetOut = Succ.WriteSetIn; }
244244

245+
/// Intersect is very frequently performed, so it is important to make it as
246+
/// cheap as possible.
247+
///
248+
/// To do so, we canonicalize MemLocations, i.e. traced back to the underlying
249+
/// object. Therefore, no need to do a O(N^2) comparison to figure out what is
250+
/// dead along all successors.
251+
///
252+
/// NOTE: Canonicalizing does not solve the problem entirely. i.e. it is still
253+
/// possible that 2 MemLocations with different bases that happen to be the
254+
/// same object and field. In such case, we would miss a dead store
255+
/// opportunity. But this happens less often with canonicalization.
245256
void BBState::intersect(const BBState &Succ) { WriteSetOut &= Succ.WriteSetIn; }
246257

247258
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)