diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2009-11-30 12:06:37 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2009-11-30 12:06:37 +0000 |
commit | f7495f497a1b9346a4d069c16b7560cd1625c1a9 (patch) | |
tree | b7237da71012bd52d437219d41927d517486373a | |
parent | 5f0988ceb02d86e25477f26be0d71d9d458e2df1 (diff) | |
download | bcm5719-llvm-f7495f497a1b9346a4d069c16b7560cd1625c1a9.tar.gz bcm5719-llvm-f7495f497a1b9346a4d069c16b7560cd1625c1a9.zip |
Small PostDominatorTree improvements
* Do not SEGFAULT if tree entryNode() is NULL
* Print function names in dotty printer
llvm-svn: 90130
-rw-r--r-- | llvm/include/llvm/Analysis/PostDominators.h | 5 | ||||
-rw-r--r-- | llvm/lib/Analysis/DomPrinter.cpp | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/llvm/include/llvm/Analysis/PostDominators.h b/llvm/include/llvm/Analysis/PostDominators.h index 42a16e74a24..ea14b2da9ce 100644 --- a/llvm/include/llvm/Analysis/PostDominators.h +++ b/llvm/include/llvm/Analysis/PostDominators.h @@ -81,7 +81,10 @@ template <> struct GraphTraits<PostDominatorTree*> } static nodes_iterator nodes_begin(PostDominatorTree *N) { - return df_begin(getEntryNode(N)); + if (getEntryNode(N)) + return df_begin(getEntryNode(N)); + else + return df_end(getEntryNode(N)); } static nodes_iterator nodes_end(PostDominatorTree *N) { diff --git a/llvm/lib/Analysis/DomPrinter.cpp b/llvm/lib/Analysis/DomPrinter.cpp index f1b44d0356e..ebfba7ef0f6 100644 --- a/llvm/lib/Analysis/DomPrinter.cpp +++ b/llvm/lib/Analysis/DomPrinter.cpp @@ -85,9 +85,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 +165,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"; |