//===----------------------------------------------------------------------===//
#include "llvm/Analysis/DataStructure/DataStructure.h"
+#include "llvm/Analysis/DataStructure/EquivClassGraphs.h"
#include "llvm/Analysis/DataStructure/DSGraph.h"
#include "llvm/Analysis/DataStructure/DSGraphTraits.h"
#include "llvm/Module.h"
if (!G) G = N->getParentGraph();
// Get the module from ONE of the functions in the graph it is available.
- if (G && !G->getReturnNodes().empty())
- M = G->getReturnNodes().begin()->first->getParent();
+ if (G && G->retnodes_begin() != G->retnodes_end())
+ M = G->retnodes_begin()->first->getParent();
if (M == 0 && G) {
// If there is a global in the graph, we can use it to find the module.
const DSScalarMap &SM = G->getScalarMap();
static void addCustomGraphFeatures(const DSGraph *G,
GraphWriter<const DSGraph*> &GW) {
Module *CurMod = 0;
- if (!G->getReturnNodes().empty())
- CurMod = G->getReturnNodes().begin()->first->getParent();
+ if (G->retnodes_begin() != G->retnodes_end())
+ CurMod = G->retnodes_begin()->first->getParent();
else {
// If there is a global in the graph, we can use it to find the module.
const DSScalarMap &SM = G->getScalarMap();
// Output the returned value pointer...
- const DSGraph::ReturnNodesTy &RetNodes = G->getReturnNodes();
- for (DSGraph::ReturnNodesTy::const_iterator I = RetNodes.begin(),
- E = RetNodes.end(); I != E; ++I)
+ for (DSGraph::retnodes_iterator I = G->retnodes_begin(),
+ E = G->retnodes_end(); I != E; ++I)
if (I->second.getNode()) {
std::string Label;
- if (RetNodes.size() == 1)
+ if (G->getReturnNodes().size() == 1)
Label = "returning";
else
Label = I->first->getName() + " ret node";
}
// Output all of the call nodes...
- const std::vector<DSCallSite> &FCs =
+ const std::list<DSCallSite> &FCs =
G->shouldPrintAuxCalls() ? G->getAuxFunctionCalls()
: G->getFunctionCalls();
- for (unsigned i = 0, e = FCs.size(); i != e; ++i) {
- const DSCallSite &Call = FCs[i];
+ for (std::list<DSCallSite>::const_iterator I = FCs.begin(), E = FCs.end();
+ I != E; ++I) {
+ const DSCallSite &Call = *I;
std::vector<std::string> EdgeSourceCaptions(Call.getNumPtrArgs()+2);
EdgeSourceCaptions[0] = "r";
if (Call.isDirectCall())
Gr.getAuxFunctionCalls().size() : Gr.getFunctionCalls().size();
TotalCallNodes += NumCalls;
- if (I->getName() == "main" || !OnlyPrintMain)
- Gr.writeGraphToFile(O, Prefix+I->getName());
- else {
+ if (I->getName() == "main" || !OnlyPrintMain) {
+ Function *SCCFn = Gr.retnodes_begin()->first;
+ if (&*I == SCCFn)
+ Gr.writeGraphToFile(O, Prefix+I->getName());
+ else
+ O << "Didn't write '" << Prefix+I->getName()
+ << ".dot' - Graph already emitted to '" << Prefix+SCCFn->getName()
+ << "\n";
+ } else {
O << "Skipped Writing '" << Prefix+I->getName() << ".dot'... ["
<< Gr.getGraphSize() << "+" << NumCalls << "]\n";
}
}
+void EquivClassGraphs::print(std::ostream &O, const Module *M) const {
+ if (DontPrintAnything) return;
+ printCollection(*this, O, M, "eq.");
+}
+