[silgen] Create CleanupManager::dump and the relevant dump methods to dump the current cleanups.

This is useful to discover when a specific cleanup is being eliminated while
debugging. The implementation is compiled out when assertions are disabled.

rdar://29791263
This commit is contained in:
Michael Gottesman
2017-01-28 19:14:41 -08:00
parent d81d37694d
commit e192b56a88
9 changed files with 143 additions and 1 deletions

View File

@@ -120,6 +120,13 @@ namespace {
void emit(SILGenFunction &gen, CleanupLocation l) override {
gen.B.emitDestroyValueOperation(l, closure);
}
void dump() const override {
#ifndef NDEBUG
llvm::errs() << "CleanupClosureConstant\n"
<< "State:" << getState() << "\n"
<< "closure:" << closure << "\n";
#endif
}
};
} // end anonymous namespace
@@ -214,6 +221,15 @@ public:
void emit(SILGenFunction &gen, CleanupLocation l) override {
gen.B.createEndBorrow(l, borrowed, original);
}
void dump() const override {
#ifndef NDEBUG
llvm::errs() << "EndBorrowCleanup "
<< "State:" << getState() << "\n"
<< "original:" << original << "\n"
<< "borrowed:" << borrowed << "\n";
#endif
}
};
} // end anonymous namespace
@@ -229,6 +245,14 @@ public:
else
gen.B.emitDestroyValueOperation(l, v);
}
void dump() const override {
#ifndef NDEBUG
llvm::errs() << "ReleaseValueCleanup\n"
<< "State:" << getState() << "\n"
<< "Value:" << v << "\n";
#endif
}
};
} // end anonymous namespace
@@ -242,6 +266,14 @@ public:
void emit(SILGenFunction &gen, CleanupLocation l) override {
gen.B.createDeallocStack(l, Addr);
}
void dump() const override {
#ifndef NDEBUG
llvm::errs() << "DeallocStackCleanup\n"
<< "State:" << getState() << "\n"
<< "Addr:" << Addr << "\n";
#endif
}
};
} // end anonymous namespace
@@ -255,6 +287,15 @@ public:
void emit(SILGenFunction &gen, CleanupLocation l) override {
gen.destroyLocalVariable(l, Var);
}
void dump() const override {
#ifndef NDEBUG
llvm::errs() << "DestroyLocalVariable\n"
<< "State:" << getState() << "\n";
// TODO: Make sure we dump var.
llvm::errs() << "\n";
#endif
}
};
} // end anonymous namespace
@@ -268,6 +309,15 @@ public:
void emit(SILGenFunction &gen, CleanupLocation l) override {
gen.deallocateUninitializedLocalVariable(l, Var);
}
void dump() const override {
#ifndef NDEBUG
llvm::errs() << "DeallocateUninitializedLocalVariable\n"
<< "State:" << getState() << "\n";
// TODO: Make sure we dump var.
llvm::errs() << "\n";
#endif
}
};
} // end anonymous namespace
@@ -1196,6 +1246,14 @@ namespace {
break;
}
}
void dump() const override {
#ifndef NDEBUG
llvm::errs() << "DeinitExistentialCleanup\n"
<< "State:" << getState() << "\n"
<< "Value:" << existentialAddr << "\n";
#endif
}
};
} // end anonymous namespace