[llvm-commits] [poolalloc] r107849 - /poolalloc/trunk/lib/DSA/DSGraph.cpp

Will Dietz wdietz2 at illinois.edu
Wed Jul 7 17:52:12 PDT 2010


Author: wdietz2
Date: Wed Jul  7 19:52:12 2010
New Revision: 107849

URL: http://llvm.org/viewvc/llvm-project?rev=107849&view=rev
Log:
When creating a DSCallsite, properly handle cases where DSA didn't create a DSNode for a value for a good reason.

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

Modified: poolalloc/trunk/lib/DSA/DSGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DSGraph.cpp?rev=107849&r1=107848&r2=107849&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DSGraph.cpp (original)
+++ poolalloc/trunk/lib/DSA/DSGraph.cpp Wed Jul  7 19:52:12 2010
@@ -31,6 +31,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/GlobalAlias.h"
 
 #include <iostream>
 #include <algorithm>
@@ -54,6 +55,26 @@
          cl::Hidden);
 }
 
+// Determines if the DSGraph 'should' have a node for a given value.
+static bool shouldHaveNodeForValue(const Value *V) {
+  // Peer through casts
+  V = V->stripPointerCasts();
+  
+  // Only pointers get nodes
+  if (!isa<PointerType>(V->getType())) return false;
+
+  // Undef values, even ones of pointer type, don't get nodes.
+  if (isa<UndefValue>(V)) return false;
+
+  // Use the Aliasee of GlobalAliases
+  // FIXME: This check might not be required, it's here because
+  // something similar is done in the Local pass.
+  if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(V))
+    return shouldHaveNodeForValue(GA->getAliasee());
+
+  return true;
+}
+
 /// getFunctionNames - Return a space separated list of the name of the
 /// functions in this graph (if any)
 std::string DSGraph::getFunctionNames() const {
@@ -517,7 +538,7 @@
 DSCallSite DSGraph::getDSCallSiteForCallSite(CallSite CS) const {
   DSNodeHandle RetVal, VarArg;
   Instruction *I = CS.getInstruction();
-  if (isa<PointerType>(I->getType()))
+  if (shouldHaveNodeForValue(I))
     RetVal = getNodeForValue(I);
 
   //FIXME: Here we trust the signature of the callsite to determine which arguments
@@ -532,7 +553,8 @@
   // Calculate the arguments vector...
   for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end(); I != E; ++I)
     if (isa<PointerType>((*I)->getType())) {
-      const DSNodeHandle ArgNode = getNodeForValue(*I);
+      DSNodeHandle ArgNode; // Initially empty
+      if (shouldHaveNodeForValue(*I)) ArgNode = getNodeForValue(*I);
       if (I - CS.arg_begin() < NumFixedArgs) {
         Args.push_back(ArgNode);
       } else {





More information about the llvm-commits mailing list