diff options
author | Chris Lattner <sabre@nondot.org> | 2002-07-18 00:12:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-07-18 00:12:30 +0000 |
commit | 0d9bab8bacc0de51c0f1a143855e53fad3f90223 (patch) | |
tree | 9dbe97e39e0c5ac3d7c721155b39f0677ff4d413 /lib/Analysis/DataStructure/Printer.cpp | |
parent | 84428e1892593c2e121fb2b869c0702a0b7230fb (diff) |
Lots of bug fixes, add BottomUpClosure, which has bugs, but is a start.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2945 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/Printer.cpp')
-rw-r--r-- | lib/Analysis/DataStructure/Printer.cpp | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/lib/Analysis/DataStructure/Printer.cpp b/lib/Analysis/DataStructure/Printer.cpp index 15f8df19ef..4a58c69afd 100644 --- a/lib/Analysis/DataStructure/Printer.cpp +++ b/lib/Analysis/DataStructure/Printer.cpp @@ -9,10 +9,11 @@ #include "llvm/Assembly/Writer.h" #include <fstream> #include <sstream> +using std::string; void DSNode::dump() const { print(std::cerr, 0); } -std::string DSNode::getCaption(const DSGraph *G) const { +string DSNode::getCaption(const DSGraph *G) const { std::stringstream OS; Module *M = G ? G->getFunction().getParent() : 0; WriteTypeSymbolic(OS, getType(), M); @@ -24,6 +25,7 @@ std::string DSNode::getCaption(const DSGraph *G) const { if (NodeType & GlobalNode) OS << "G"; if (NodeType & SubElement) OS << "E"; if (NodeType & CastNode ) OS << "C"; + if (NodeType & Incomplete) OS << "I"; for (unsigned i = 0, e = Globals.size(); i != e; ++i) { OS << "\n"; @@ -43,7 +45,7 @@ std::string DSNode::getCaption(const DSGraph *G) const { return OS.str(); } -static std::string getValueName(Value *V, Function &F) { +static string getValueName(Value *V, Function &F) { std::stringstream OS; WriteAsOperand(OS, V, true, true, F.getParent()); return OS.str(); @@ -51,7 +53,7 @@ static std::string getValueName(Value *V, Function &F) { -static void replaceIn(std::string &S, char From, const std::string &To) { +static void replaceIn(string &S, char From, const string &To) { for (unsigned i = 0; i < S.size(); ) if (S[i] == From) { S.replace(S.begin()+i, S.begin()+i+1, @@ -144,23 +146,32 @@ void DSGraph::print(std::ostream &O) const { O << "}\n"; } - - - -// print - Print out the analysis results... -void LocalDataStructures::print(std::ostream &O, Module *M) const { +template <typename Collection> +static void printCollection(const Collection &C, std::ostream &O, Module *M, + const string &Prefix) { for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) if (!I->isExternal()) { - std::string Filename = "ds." + I->getName() + ".dot"; + string Filename = Prefix + "." + I->getName() + ".dot"; O << "Writing '" << Filename << "'..."; std::ofstream F(Filename.c_str()); - + if (F.good()) { - DSGraph &Graph = getDSGraph(*I); + DSGraph &Graph = C.getDSGraph(*I); Graph.print(F); - O << " [" << Graph.getGraphSize() << "]\n"; + O << " [" << Graph.getGraphSize() << "+" + << Graph.getFunctionCalls().size() << "]\n"; } else { O << " error opening file for writing!\n"; } } } + + +// print - Print out the analysis results... +void LocalDataStructures::print(std::ostream &O, Module *M) const { + printCollection(*this, O, M, "ds"); +} + +void BUDataStructures::print(std::ostream &O, Module *M) const { + printCollection(*this, O, M, "bu"); +} |