Skip to content

Commit 1c0dcc1

Browse files
committed
DeadStoreElimination: add debug dump functions
NFC
1 parent 33afd0e commit 1c0dcc1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

lib/SILOptimizer/Transforms/DeadStoreElimination.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include "swift/SIL/Projection.h"
6161
#include "swift/SIL/SILArgument.h"
6262
#include "swift/SIL/SILBuilder.h"
63+
#include "swift/SIL/MemoryLifetime.h"
6364
#include "swift/SILOptimizer/Analysis/AliasAnalysis.h"
6465
#include "swift/SILOptimizer/Analysis/PostOrderAnalysis.h"
6566
#include "swift/SILOptimizer/PassManager/Passes.h"
@@ -269,6 +270,8 @@ class BlockState {
269270
init(LocationNum, Optimistic);
270271
}
271272

273+
void dump();
274+
272275
/// Initialize the bitvectors for the current basic block.
273276
void init(unsigned LocationNum, bool Optimistic);
274277

@@ -448,6 +451,8 @@ enum class ProcessKind {
448451
llvm::SpecificBumpPtrAllocator<BlockState> &BPA)
449452
: Mod(M), F(F), PM(PM), AA(AA), TE(TE), EAFI(EAFI), BPA(BPA) {}
450453

454+
void dump();
455+
451456
/// Entry point for dead store elimination.
452457
bool run();
453458

@@ -481,6 +486,12 @@ enum class ProcessKind {
481486

482487
} // end anonymous namespace
483488

489+
void BlockState::dump() {
490+
llvm::dbgs() << " block " << BB->getDebugID() << ": in=" << BBWriteSetIn
491+
<< ", out=" << BBWriteSetOut << ", mid=" << BBWriteSetMid
492+
<< ", gen=" << BBGenSet << ", kill=" << BBKillSet << '\n';
493+
}
494+
484495
void BlockState::init(unsigned LocationNum, bool Optimistic) {
485496
// For function that requires just 1 iteration of the data flow to converge
486497
// we set the initial state of BBWriteSetIn to 0.
@@ -513,6 +524,21 @@ void BlockState::init(unsigned LocationNum, bool Optimistic) {
513524
BBDeallocateLocation.resize(LocationNum, false);
514525
}
515526

527+
#if __has_attribute(used)
528+
__attribute((used))
529+
#endif
530+
void DSEContext::dump() {
531+
llvm::dbgs() << "Locations:\n";
532+
unsigned idx = 0;
533+
for (const LSLocation &loc : LocationVault) {
534+
llvm::dbgs() << " #" << idx << ": " << loc.getBase();
535+
++idx;
536+
}
537+
for (SILBasicBlock &BB : *F) {
538+
getBlockState(&BB)->dump();
539+
}
540+
}
541+
516542
unsigned DSEContext::getLocationBit(const LSLocation &Loc) {
517543
// Return the bit position of the given Loc in the LocationVault. The bit
518544
// position is then used to set/reset the bitvector kept by each BlockState.

0 commit comments

Comments
 (0)