Add special case handling for calloc and realloc
authorChris Lattner <sabre@nondot.org>
Sat, 20 Sep 2003 16:50:46 +0000 (16:50 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 20 Sep 2003 16:50:46 +0000 (16:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8630 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/DataStructure/Local.cpp

index 1b082833de5eaf8cf947e6441f0c530bfd585f5d..43edb18433bb1a0b03b4cb22752632b899d12cde 100644 (file)
@@ -412,6 +412,22 @@ void GraphBuilder::visitInvokeInst(InvokeInst &II) {
 }
 
 void GraphBuilder::visitCallSite(CallSite CS) {
+  // Special case handling of certain libc allocation functions here.
+  if (Function *F = CS.getCalledFunction())
+    if (F->isExternal())
+      if (F->getName() == "calloc") {
+        setDestTo(*CS.getInstruction(),
+                  createNode()->setHeapNodeMarker()->setModifiedMarker());
+        return;
+      } else if (F->getName() == "realloc") {
+        DSNodeHandle RetNH = getValueDest(*CS.getInstruction());
+        RetNH.mergeWith(getValueDest(**CS.arg_begin()));
+        DSNode *N = RetNH.getNode();
+        if (N) N->setHeapNodeMarker()->setModifiedMarker()->setReadMarker();
+        return;
+      }
+
+
   // Set up the return value...
   DSNodeHandle RetVal;
   Instruction *I = CS.getInstruction();