forked from OSchip/llvm-project
Added a command line option that allows the user to specify a list of
functions that allocate memory. llvm-svn: 24862
This commit is contained in:
parent
9b9688aeb8
commit
aa0fed0148
|
@ -39,6 +39,12 @@ static cl::opt<bool>
|
||||||
TrackIntegersAsPointers("dsa-track-integers", cl::Hidden,
|
TrackIntegersAsPointers("dsa-track-integers", cl::Hidden,
|
||||||
cl::desc("If this is set, track integers as potential pointers"));
|
cl::desc("If this is set, track integers as potential pointers"));
|
||||||
|
|
||||||
|
static cl::list<std::string>
|
||||||
|
AllocList("alloc-list",
|
||||||
|
cl::value_desc("list"),
|
||||||
|
cl::desc("List of functions that allocate memory from the heap"),
|
||||||
|
cl::CommaSeparated);
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
namespace DS {
|
namespace DS {
|
||||||
// isPointerType - Return true if this type is big enough to hold a pointer.
|
// isPointerType - Return true if this type is big enough to hold a pointer.
|
||||||
|
@ -548,6 +554,19 @@ void GraphBuilder::visitCallSite(CallSite CS) {
|
||||||
N->setModifiedMarker();
|
N->setModifiedMarker();
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
// Determine if the called function is one of the specified heap
|
||||||
|
// allocation functions
|
||||||
|
for (cl::list<std::string>::iterator AllocFunc = AllocList.begin(),
|
||||||
|
LastAllocFunc = AllocList.end();
|
||||||
|
AllocFunc != LastAllocFunc;
|
||||||
|
++AllocFunc) {
|
||||||
|
if (F->getName() == *(AllocFunc)) {
|
||||||
|
setDestTo(*CS.getInstruction(),
|
||||||
|
createNode()->setHeapNodeMarker()->setModifiedMarker());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (F->getName() == "calloc" || F->getName() == "posix_memalign" ||
|
if (F->getName() == "calloc" || F->getName() == "posix_memalign" ||
|
||||||
F->getName() == "memalign" || F->getName() == "valloc") {
|
F->getName() == "memalign" || F->getName() == "valloc") {
|
||||||
setDestTo(*CS.getInstruction(),
|
setDestTo(*CS.getInstruction(),
|
||||||
|
|
Loading…
Reference in New Issue