Add support for memmove
[oota-llvm.git] / lib / Analysis / DataStructure / Local.cpp
index 689373ee7d23f2e95ed2747ee68e20ed959b667e..0aca21a437ba90fcbb2aa3b5e1b2fd176b4da06a 100644 (file)
@@ -435,8 +435,31 @@ void GraphBuilder::visitCallSite(CallSite CS) {
       } 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();
+        if (DSNode *N = RetNH.getNode())
+          N->setHeapNodeMarker()->setModifiedMarker()->setReadMarker();
+        return;
+      } else if (F->getName() == "memset") {
+        // Merge the first argument with the return value, and mark the memory
+        // modified.
+        DSNodeHandle RetNH = getValueDest(*CS.getInstruction());
+        RetNH.mergeWith(getValueDest(**CS.arg_begin()));
+        if (DSNode *N = RetNH.getNode())
+          N->setModifiedMarker();
+        return;
+      } else if (F->getName() == "memmove") {
+        // Merge the first & second arguments with the result, and mark the
+        // memory read and modified.
+        DSNodeHandle RetNH = getValueDest(*CS.getInstruction());
+        RetNH.mergeWith(getValueDest(**CS.arg_begin()));
+        RetNH.mergeWith(getValueDest(**(CS.arg_begin()+1)));
+        if (DSNode *N = RetNH.getNode())
+          N->setModifiedMarker()->setReadMarker();
+        return;
+      } else if (F->getName() == "bzero") {
+        // Mark the memory modified.
+        DSNodeHandle H = getValueDest(**CS.arg_begin());
+        if (DSNode *N = H.getNode())
+          N->setModifiedMarker();
         return;
       }