[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Local.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Feb 26 16:08:01 PST 2004


Changes in directory llvm/lib/Analysis/DataStructure:

Local.cpp updated: 1.92 -> 1.93

---
Log message:

Be a good little compiler and handle direct calls efficiently, even if there
are beastly ConstantPointerRefs in the way...


---
Diffs of the changes:  (+13 -10)

Index: llvm/lib/Analysis/DataStructure/Local.cpp
diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.92 llvm/lib/Analysis/DataStructure/Local.cpp:1.93
--- llvm/lib/Analysis/DataStructure/Local.cpp:1.92	Wed Feb 25 21:43:08 2004
+++ llvm/lib/Analysis/DataStructure/Local.cpp	Thu Feb 26 16:07:22 2004
@@ -465,8 +465,12 @@
 }
 
 void GraphBuilder::visitCallSite(CallSite CS) {
+  Value *Callee = CS.getCalledValue();
+  if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Callee))
+    Callee = CPR->getValue();
+
   // Special case handling of certain libc allocation functions here.
-  if (Function *F = CS.getCalledFunction())
+  if (Function *F = dyn_cast<Function>(Callee))
     if (F->isExternal())
       switch (F->getIntrinsicID()) {
       case Intrinsic::memmove:
@@ -809,12 +813,11 @@
   if (isPointerType(I->getType()))
     RetVal = getValueDest(*I);
 
-  DSNode *Callee = 0;
-  if (DisableDirectCallOpt || !isa<Function>(CS.getCalledValue())) {
-    Callee = getValueDest(*CS.getCalledValue()).getNode();
-    if (Callee == 0) {
-      std::cerr << "WARNING: Program is calling through a null pointer?\n"
-                << *I;
+  DSNode *CalleeNode = 0;
+  if (DisableDirectCallOpt || !isa<Function>(Callee)) {
+    CalleeNode = getValueDest(*Callee).getNode();
+    if (CalleeNode == 0) {
+      std::cerr << "WARNING: Program is calling through a null pointer?\n"<< *I;
       return;  // Calling a null pointer?
     }
   }
@@ -828,10 +831,10 @@
       Args.push_back(getValueDest(**I));
 
   // Add a new function call entry...
-  if (Callee)
-    FunctionCalls->push_back(DSCallSite(CS, RetVal, Callee, Args));
+  if (CalleeNode)
+    FunctionCalls->push_back(DSCallSite(CS, RetVal, CalleeNode, Args));
   else
-    FunctionCalls->push_back(DSCallSite(CS, RetVal, CS.getCalledFunction(),
+    FunctionCalls->push_back(DSCallSite(CS, RetVal, cast<Function>(Callee),
                                         Args));
 }
 





More information about the llvm-commits mailing list