[llvm-commits] [poolalloc] r108577 - /poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp

Will Dietz wdietz2 at illinois.edu
Fri Jul 16 17:02:12 PDT 2010


Author: wdietz2
Date: Fri Jul 16 19:02:12 2010
New Revision: 108577

URL: http://llvm.org/viewvc/llvm-project?rev=108577&view=rev
Log:
In CBU, be robust to callee's that don't exist.
Additionally added sanity check that we have entries that we expect to have.

Modified:
    poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp

Modified: poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp?rev=108577&r1=108576&r2=108577&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp (original)
+++ poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp Fri Jul 16 19:02:12 2010
@@ -51,16 +51,48 @@
   //mege nodes in the global graph for these functions
   for (DSCallGraph::callee_key_iterator ii = callgraph.key_begin(),
        ee = callgraph.key_end(); ii != ee; ++ii) {
+
+#ifndef NDEBUG
+    // --Verify that for every callee of an indirect function call
+    //   we have an entry in the GlobalsGraph
+    bool isIndirect = ((*ii).getCalledFunction() == NULL);
+
+    if (isIndirect) {
+      DSCallGraph::callee_iterator csii = callgraph.callee_begin(*ii),
+                                   csee = callgraph.callee_end(*ii);
+
+      for (; csii != csee; ++csii) {
+        // Declarations don't have to have entries
+        if(!(*csii)->isDeclaration())
+          assert(SM.count(*csii) && "Indirect function callee not in globals?");
+      }
+
+    }
+#endif
+    // FIXME: Given the above is a valid assertion, we could probably replace
+    // this code with something that *assumes* we have entries.  However because
+    // I'm not convinced that we can just *skip* direct calls in this function
+    // this code is careful to handle callees not existing in the globals graph
+    // In other words what we have here should be correct, but might be overkill
+    // that we can trim down later as needed.
+
     DSCallGraph::callee_iterator csi = callgraph.callee_begin(*ii),
             cse = callgraph.callee_end(*ii);
-    if (csi != cse && SM.find(*csi) != SM.end()) {
-      assert((SM.find(*csi) != SM.end()) && "Function not in Global graph?");
-      DSNodeHandle& SrcNH = SM.find(*csi)->second;
+
+    // Grab the first callee we have an entry for...
+    while (csi != cse && !SM.count(*csi))
       ++csi;
-      for (; csi != cse; ++csi) {
-        assert((SM.find(*csi) != SM.end()) && "Function not in Global graph?");
+
+    // If we have no entries, we're done.
+    if (csi == cse) break;
+
+    DSNodeHandle& SrcNH = SM.find(*csi)->second;
+
+    // Merge the rest of the callees (that we have entries for) together
+    // with the first one.
+    for (; csi != cse; ++csi) {
+      if (SM.count(*csi))
         SrcNH.mergeWith(SM.find(*csi)->second);
-      }
     }
   }
 }





More information about the llvm-commits mailing list