Simplify graph traversal, improve grammar
authorChris Lattner <sabre@nondot.org>
Sun, 31 Oct 2004 23:01:34 +0000 (23:01 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 31 Oct 2004 23:01:34 +0000 (23:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17383 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/DataStructure/EquivClassGraphs.h
lib/Analysis/DataStructure/EquivClassGraphs.cpp

index ea41ac33df2ff4e6b424c8c91bcbdb403790d20e..a46da411863e857856119078cb457669e482a7b7 100644 (file)
@@ -141,7 +141,7 @@ namespace PA {
 
     unsigned processSCC(DSGraph &FG, Function &F, std::vector<Function*> &Stack,
                         unsigned &NextID, 
-                        hash_map<Function*, unsigned> &ValMap);
+                        std::map<Function*, unsigned> &ValMap);
 
     void processGraph(DSGraph &FG, Function &F);
 
index 4c00b7aad9d25e51bca5a5c2761f87dfad09c1a8..caaf43fac65620ca607ea2d66490195bb4815b11 100644 (file)
@@ -37,7 +37,6 @@ namespace {
                                   "Number of graphs inlined");
 }
 
-
 // getDSGraphForCallSite - Return the common data structure graph for
 // callees at the specified call site.
 // 
@@ -67,7 +66,7 @@ bool PA::EquivClassGraphs::runOnModule(Module &M) {
 
   // Stack of functions used for Tarjan's SCC-finding algorithm.
   std::vector<Function*> Stack;
-  hash_map<Function*, unsigned> ValMap;
+  std::map<Function*, unsigned> ValMap;
   unsigned NextID = 1;
 
   if (Function *Main = M.getMainFunction()) {
@@ -259,13 +258,16 @@ DSGraph *PA::EquivClassGraphs::cloneGraph(Function &F) {
 }
 
 
-unsigned PA::EquivClassGraphs::processSCC(DSGraph &FG, FunctionF,
+unsigned PA::EquivClassGraphs::processSCC(DSGraph &FG, Function &F,
                                           std::vector<Function*> &Stack,
                                           unsigned &NextID, 
-                                          hash_map<Function*,unsigned> &ValMap){
+                                          std::map<Function*,unsigned> &ValMap){
   DEBUG(std::cerr << "    ProcessSCC for function " << F.getName() << "\n");
 
-  assert(!ValMap.count(&F) && "Shouldn't revisit functions!");
+  std::map<Function*, unsigned>::iterator It = ValMap.lower_bound(&F);
+  if (It != ValMap.end() && It->first == &F)
+    return It->second;
+
   unsigned Min = NextID++, MyID = Min;
   ValMap[&F] = Min;
   Stack.push_back(&F);
@@ -281,11 +283,8 @@ unsigned PA::EquivClassGraphs::processSCC(DSGraph &FG, Function& F,
         DSGraph &CalleeG = getOrCreateGraph(*I->second);
 
         // Have we visited the destination function yet?
-        hash_map<Function*, unsigned>::iterator It = ValMap.find(I->second);
-        unsigned M = (It == ValMap.end())  // No, visit it now.
-          ? processSCC(CalleeG, *I->second, Stack, NextID, ValMap)
-          : It->second;                    // Yes, get it's number.
-        
+        std::map<Function*, unsigned>::iterator It = ValMap.find(I->second);
+        unsigned M = processSCC(CalleeG, *I->second, Stack, NextID, ValMap);
         if (M < Min) Min = M;
       }
   }