diff options
author | Duncan Sands <baldrick@free.fr> | 2008-09-29 14:59:04 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2008-09-29 14:59:04 +0000 |
commit | 57512a1be4850a3469caea34f3a1133f849f0f99 (patch) | |
tree | 983840a83f9a87f6ea542ab2be79104f0dc3c954 /llvm/lib/Transforms/IPO/PruneEH.cpp | |
parent | ffc9da67725999f98f0e7770d5db5c6d00016ce0 (diff) | |
download | bcm5719-llvm-57512a1be4850a3469caea34f3a1133f849f0f99.tar.gz bcm5719-llvm-57512a1be4850a3469caea34f3a1133f849f0f99.zip |
Speed up these passes when the callgraph has
huge simply connected components. Suggested
by Chris.
llvm-svn: 56787
Diffstat (limited to 'llvm/lib/Transforms/IPO/PruneEH.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/PruneEH.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/PruneEH.cpp b/llvm/lib/Transforms/IPO/PruneEH.cpp index adaa9c16809..c7a4b9766a5 100644 --- a/llvm/lib/Transforms/IPO/PruneEH.cpp +++ b/llvm/lib/Transforms/IPO/PruneEH.cpp @@ -21,6 +21,7 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Analysis/CallGraph.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/CFG.h" @@ -53,9 +54,15 @@ Pass *llvm::createPruneEHPass() { return new PruneEH(); } bool PruneEH::runOnSCC(const std::vector<CallGraphNode *> &SCC) { + SmallPtrSet<CallGraphNode *, 8> SCCNodes; CallGraph &CG = getAnalysis<CallGraph>(); bool MadeChange = false; + // Fill SCCNodes with the elements of the SCC. Used for quickly + // looking up whether a given CallGraphNode is in this SCC. + for (unsigned i = 0, e = SCC.size(); i != e; ++i) + SCCNodes.insert(SCC[i]); + // First pass, scan all of the functions in the SCC, simplifying them // according to what we know. for (unsigned i = 0, e = SCC.size(); i != e; ++i) @@ -107,7 +114,7 @@ bool PruneEH::runOnSCC(const std::vector<CallGraphNode *> &SCC) { CallGraphNode *CalleeNode = CG[Callee]; // If the callee is outside our current SCC then we may // throw because it might. - if (std::find(SCC.begin(), SCC.end(), CalleeNode) == SCC.end()){ + if (!SCCNodes.count(CalleeNode)) { SCCMightUnwind = true; break; } |