summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-13 16:09:54 +0000
committerChris Lattner <sabre@nondot.org>2004-02-13 16:09:54 +0000
commita07b72ff3d4b5522de8f6d3009cdc2a87e923730 (patch)
treef0dd6ad312a0b6e20fc57dabbf1487b51dc76fee
parentc201a7a91133303e4489e78da00ce37097ef8e6f (diff)
downloadllvm-a07b72ff3d4b5522de8f6d3009cdc2a87e923730.tar.gz
llvm-a07b72ff3d4b5522de8f6d3009cdc2a87e923730.tar.bz2
llvm-a07b72ff3d4b5522de8f6d3009cdc2a87e923730.tar.xz
Restructure code to handle memcpy/memmove
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11374 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/DataStructure/Local.cpp61
1 files changed, 33 insertions, 28 deletions
diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp
index 22a60414d3..2a04d29128 100644
--- a/lib/Analysis/DataStructure/Local.cpp
+++ b/lib/Analysis/DataStructure/Local.cpp
@@ -17,6 +17,7 @@
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h"
+#include "llvm/Intrinsics.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Target/TargetData.h"
@@ -456,39 +457,43 @@ 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()));
- 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
+ switch (F->getIntrinsicID()) {
+ case Intrinsic::memmove:
+ case Intrinsic::memcpy: {
+ // Merge the first & second arguments, and mark the memory read and
// 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()));
+ DSNodeHandle RetNH = 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;
+ }
+ default:
+ 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()));
+ 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() == "bzero") {
+ // Mark the memory modified.
+ DSNodeHandle H = getValueDest(**CS.arg_begin());
+ if (DSNode *N = H.getNode())
+ N->setModifiedMarker();
+ return;
+ }
}