|
60 | 60 | #include "swift/SIL/Projection.h"
|
61 | 61 | #include "swift/SIL/SILArgument.h"
|
62 | 62 | #include "swift/SIL/SILBuilder.h"
|
| 63 | +#include "swift/SIL/MemoryLifetime.h" |
63 | 64 | #include "swift/SILOptimizer/Analysis/AliasAnalysis.h"
|
64 | 65 | #include "swift/SILOptimizer/Analysis/PostOrderAnalysis.h"
|
65 | 66 | #include "swift/SILOptimizer/PassManager/Passes.h"
|
@@ -269,6 +270,8 @@ class BlockState {
|
269 | 270 | init(LocationNum, Optimistic);
|
270 | 271 | }
|
271 | 272 |
|
| 273 | + void dump(); |
| 274 | + |
272 | 275 | /// Initialize the bitvectors for the current basic block.
|
273 | 276 | void init(unsigned LocationNum, bool Optimistic);
|
274 | 277 |
|
@@ -448,6 +451,8 @@ enum class ProcessKind {
|
448 | 451 | llvm::SpecificBumpPtrAllocator<BlockState> &BPA)
|
449 | 452 | : Mod(M), F(F), PM(PM), AA(AA), TE(TE), EAFI(EAFI), BPA(BPA) {}
|
450 | 453 |
|
| 454 | + void dump(); |
| 455 | + |
451 | 456 | /// Entry point for dead store elimination.
|
452 | 457 | bool run();
|
453 | 458 |
|
@@ -481,6 +486,12 @@ enum class ProcessKind {
|
481 | 486 |
|
482 | 487 | } // end anonymous namespace
|
483 | 488 |
|
| 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 | + |
484 | 495 | void BlockState::init(unsigned LocationNum, bool Optimistic) {
|
485 | 496 | // For function that requires just 1 iteration of the data flow to converge
|
486 | 497 | // we set the initial state of BBWriteSetIn to 0.
|
@@ -513,6 +524,21 @@ void BlockState::init(unsigned LocationNum, bool Optimistic) {
|
513 | 524 | BBDeallocateLocation.resize(LocationNum, false);
|
514 | 525 | }
|
515 | 526 |
|
| 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 | + |
516 | 542 | unsigned DSEContext::getLocationBit(const LSLocation &Loc) {
|
517 | 543 | // Return the bit position of the given Loc in the LocationVault. The bit
|
518 | 544 | // position is then used to set/reset the bitvector kept by each BlockState.
|
|
0 commit comments