diff options
| author | Roman Divacky <rdivacky@FreeBSD.org> | 2009-12-01 11:07:05 +0000 | 
|---|---|---|
| committer | Roman Divacky <rdivacky@FreeBSD.org> | 2009-12-01 11:07:05 +0000 | 
| commit | 06f9d4012fb8acea3e9861d5722b5965dbb724d9 (patch) | |
| tree | ffe0478472eaa0686f11cb02c6df7d257b8719b0 /lib/Analysis/DomPrinter.cpp | |
| parent | 76e2e0ebfdd3d91b07a75822865ea3e9121a99ce (diff) | |
Notes
Diffstat (limited to 'lib/Analysis/DomPrinter.cpp')
| -rw-r--r-- | lib/Analysis/DomPrinter.cpp | 51 | 
1 files changed, 33 insertions, 18 deletions
| diff --git a/lib/Analysis/DomPrinter.cpp b/lib/Analysis/DomPrinter.cpp index f1b44d0356ea..32b8994f0289 100644 --- a/lib/Analysis/DomPrinter.cpp +++ b/lib/Analysis/DomPrinter.cpp @@ -30,46 +30,55 @@ using namespace llvm;  namespace llvm {  template<>  struct DOTGraphTraits<DomTreeNode*> : public DefaultDOTGraphTraits { -  static std::string getNodeLabel(DomTreeNode *Node, DomTreeNode *Graph, -                                  bool ShortNames) { + +  DOTGraphTraits (bool isSimple=false) +    : DefaultDOTGraphTraits(isSimple) {} + +  std::string getNodeLabel(DomTreeNode *Node, DomTreeNode *Graph) {      BasicBlock *BB = Node->getBlock();      if (!BB)        return "Post dominance root node"; -    return DOTGraphTraits<const Function*>::getNodeLabel(BB, BB->getParent(), -                                                         ShortNames); + +    if (isSimple()) +      return DOTGraphTraits<const Function*> +	       ::getSimpleNodeLabel(BB, BB->getParent()); +    else +      return DOTGraphTraits<const Function*> +	       ::getCompleteNodeLabel(BB, BB->getParent());    }  };  template<>  struct DOTGraphTraits<DominatorTree*> : public DOTGraphTraits<DomTreeNode*> { +  DOTGraphTraits (bool isSimple=false) +    : DOTGraphTraits<DomTreeNode*>(isSimple) {} +    static std::string getGraphName(DominatorTree *DT) {      return "Dominator tree";    } -  static std::string getNodeLabel(DomTreeNode *Node, -                                  DominatorTree *G, -                                  bool ShortNames) { -    return DOTGraphTraits<DomTreeNode*>::getNodeLabel(Node, G->getRootNode(), -                                                      ShortNames); +  std::string getNodeLabel(DomTreeNode *Node, DominatorTree *G) { +    return DOTGraphTraits<DomTreeNode*>::getNodeLabel(Node, G->getRootNode());    }  };  template<>  struct DOTGraphTraits<PostDominatorTree*>    : public DOTGraphTraits<DomTreeNode*> { + +  DOTGraphTraits (bool isSimple=false) +    : DOTGraphTraits<DomTreeNode*>(isSimple) {} +    static std::string getGraphName(PostDominatorTree *DT) {      return "Post dominator tree";    } -  static std::string getNodeLabel(DomTreeNode *Node, -                                  PostDominatorTree *G, -                                  bool ShortNames) { -    return DOTGraphTraits<DomTreeNode*>::getNodeLabel(Node, -                                                      G->getRootNode(), -                                                      ShortNames); + +  std::string getNodeLabel(DomTreeNode *Node, PostDominatorTree *G ) { +    return DOTGraphTraits<DomTreeNode*>::getNodeLabel(Node, G->getRootNode());    }  };  } @@ -85,9 +94,11 @@ struct GenericGraphViewer : public FunctionPass {    virtual bool runOnFunction(Function &F) {      Analysis *Graph; - +    std::string Title, GraphName;      Graph = &getAnalysis<Analysis>(); -    ViewGraph(Graph, Name, OnlyBBS); +    GraphName = DOTGraphTraits<Analysis*>::getGraphName(Graph); +    Title = GraphName + " for '" + F.getNameStr() + "' function"; +    ViewGraph(Graph, Name, OnlyBBS, Title);      return false;    } @@ -163,8 +174,12 @@ struct GenericGraphPrinter : public FunctionPass {      raw_fd_ostream File(Filename.c_str(), ErrorInfo);      Graph = &getAnalysis<Analysis>(); +    std::string Title, GraphName; +    GraphName = DOTGraphTraits<Analysis*>::getGraphName(Graph); +    Title = GraphName + " for '" + F.getNameStr() + "' function"; +      if (ErrorInfo.empty()) -      WriteGraph(File, Graph, OnlyBBS); +      WriteGraph(File, Graph, OnlyBBS, Name, Title);      else        errs() << "  error opening file for writing!";      errs() << "\n"; | 
