Add support for ensuring that nodes are not incomplete

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6985 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2003-06-29 22:36:15 +00:00
parent ca29178bb9
commit 919ffbf977

View File

@ -9,6 +9,8 @@
// --dsgc-abort-if-any-collapsed - Abort if any collapsed nodes are found // --dsgc-abort-if-any-collapsed - Abort if any collapsed nodes are found
// --dsgc-abort-if-collapsed=<list> - Abort if a node pointed to by an SSA // --dsgc-abort-if-collapsed=<list> - Abort if a node pointed to by an SSA
// value with name in <list> is collapsed // value with name in <list> is collapsed
// --dsgc-abort-if-incomplete=<list>- Abort if any of the named SSA values
// are incomplete.
// --dsgc-abort-if-merged=<list> - Abort if any of the named SSA values // --dsgc-abort-if-merged=<list> - Abort if any of the named SSA values
// point to the same node. // point to the same node.
// //
@ -36,6 +38,9 @@ namespace {
AbortIfCollapsed("dsgc-abort-if-collapsed", cl::Hidden, cl::CommaSeparated, AbortIfCollapsed("dsgc-abort-if-collapsed", cl::Hidden, cl::CommaSeparated,
cl::desc("Abort if any of the named symbols is collapsed")); cl::desc("Abort if any of the named symbols is collapsed"));
cl::list<std::string> cl::list<std::string>
AbortIfIncomplete("dsgc-abort-if-incomplete", cl::Hidden, cl::CommaSeparated,
cl::desc("Abort if any of the named symbols is incomplete"));
cl::list<std::string>
AbortIfMerged("dsgc-abort-if-merged", cl::Hidden, cl::CommaSeparated, AbortIfMerged("dsgc-abort-if-merged", cl::Hidden, cl::CommaSeparated,
cl::desc("Abort if any of the named symbols are merged together")); cl::desc("Abort if any of the named symbols are merged together"));
@ -63,7 +68,7 @@ namespace {
DSGC::DSGC() { DSGC::DSGC() {
if (!AbortIfAnyCollapsed && AbortIfCollapsed.empty() && if (!AbortIfAnyCollapsed && AbortIfCollapsed.empty() &&
AbortIfMerged.empty()) { AbortIfIncomplete.empty() && AbortIfMerged.empty()) {
std::cerr << "The -datastructure-gc is useless if you don't specify any" std::cerr << "The -datastructure-gc is useless if you don't specify any"
" -dsgc-* options. See the -help-hidden output for a list.\n"; " -dsgc-* options. See the -help-hidden output for a list.\n";
abort(); abort();
@ -109,11 +114,14 @@ void DSGC::verify(const DSGraph &G) {
} }
} }
if (!AbortIfCollapsed.empty() || !AbortIfMerged.empty()) { if (!AbortIfCollapsed.empty() || !AbortIfIncomplete.empty() ||
!AbortIfMerged.empty()) {
// Convert from a list to a set, because we don't have cl::set's yet. FIXME // Convert from a list to a set, because we don't have cl::set's yet. FIXME
std::set<std::string> AbortIfCollapsedS(AbortIfCollapsed.begin(), std::set<std::string> AbortIfCollapsedS(AbortIfCollapsed.begin(),
AbortIfCollapsed.end()); AbortIfCollapsed.end());
std::set<std::string> AbortIfMerged(AbortIfMerged.begin(), std::set<std::string> AbortIfIncompleteS(AbortIfIncomplete.begin(),
AbortIfIncomplete.end());
std::set<std::string> AbortIfMergedS(AbortIfMerged.begin(),
AbortIfMerged.end()); AbortIfMerged.end());
@ -125,26 +133,31 @@ void DSGC::verify(const DSGraph &G) {
for (DSGraph::ScalarMapTy::const_iterator I = SM.begin(), E = SM.end(); for (DSGraph::ScalarMapTy::const_iterator I = SM.begin(), E = SM.end();
I != E; ++I) I != E; ++I)
if (I->first->hasName() && I->second.getNode()) { if (I->first->hasName() && I->second.getNode()) {
std::string Name = I->first->getName();
DSNode *N = I->second.getNode(); DSNode *N = I->second.getNode();
// Verify it is not collapsed if it is not supposed to be... // Verify it is not collapsed if it is not supposed to be...
if (N->isNodeCompletelyFolded() && if (N->isNodeCompletelyFolded() && AbortIfCollapsedS.count(Name)) {
AbortIfCollapsedS.count(I->first->getName())) { std::cerr << "Node for value '%" << Name << "' is collapsed: ";
std::cerr << "Node for value '%" << I->first->getName() N->print(std::cerr, &G);
<< "' is collapsed: "; abort();
}
if (N->isIncomplete() && AbortIfIncompleteS.count(Name)) {
std::cerr << "Node for value '%" << Name << "' is incomplete: ";
N->print(std::cerr, &G); N->print(std::cerr, &G);
abort(); abort();
} }
// Verify that it is not merged if it is not supposed to be... // Verify that it is not merged if it is not supposed to be...
if (AbortIfMerged.count(I->first->getName())) { if (AbortIfMergedS.count(Name)) {
if (AbortIfMergedNodes.count(N)) { if (AbortIfMergedNodes.count(N)) {
std::cerr << "Nodes for values '%" << I->first->getName() std::cerr << "Nodes for values '%" << Name << "' and '%"
<< "' and '%" << AbortIfMergedNodes[N] << "' is merged: "; << AbortIfMergedNodes[N] << "' is merged: ";
N->print(std::cerr, &G); N->print(std::cerr, &G);
abort(); abort();
} }
AbortIfMergedNodes[N] = I->first->getName(); AbortIfMergedNodes[N] = Name;
} }
} }
} }