Added an option to specify the names of heap freeing functions.
llvm-svn: 24863
This commit is contained in:
parent
aa0fed0148
commit
45bb70d8f9
|
@ -45,6 +45,12 @@ AllocList("alloc-list",
|
||||||
cl::desc("List of functions that allocate memory from the heap"),
|
cl::desc("List of functions that allocate memory from the heap"),
|
||||||
cl::CommaSeparated);
|
cl::CommaSeparated);
|
||||||
|
|
||||||
|
static cl::list<std::string>
|
||||||
|
FreeList("free-list",
|
||||||
|
cl::value_desc("list"),
|
||||||
|
cl::desc("List of functions that free 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.
|
||||||
|
@ -567,6 +573,20 @@ void GraphBuilder::visitCallSite(CallSite CS) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine if the called function is one of the specified heap
|
||||||
|
// free functions
|
||||||
|
for (cl::list<std::string>::iterator FreeFunc = FreeList.begin(),
|
||||||
|
LastFreeFunc = FreeList.end();
|
||||||
|
FreeFunc != LastFreeFunc;
|
||||||
|
++FreeFunc) {
|
||||||
|
if (F->getName() == *(FreeFunc)) {
|
||||||
|
// Mark that the node is written to...
|
||||||
|
if (DSNode *N = getValueDest(*(CS.getArgument(0))).getNode())
|
||||||
|
N->setModifiedMarker()->setHeapNodeMarker();
|
||||||
|
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