[llvm-commits] [poolalloc] r132932 - in /poolalloc/trunk: lib/AssistDS/TypeChecks.cpp runtime/DynamicTypeChecks/TypeRuntime.c
Arushi Aggarwal
aggarwa4 at illinois.edu
Mon Jun 13 14:02:05 PDT 2011
Author: aggarwa4
Date: Mon Jun 13 16:02:05 2011
New Revision: 132932
URL: http://llvm.org/viewvc/llvm-project?rev=132932&view=rev
Log:
Add tracking for strcat.
Add tracking for getrusage.(Used widely in MallocBench/espresso)
Modified:
poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c
Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=132932&r1=132931&r2=132932&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Mon Jun 13 16:02:05 2011
@@ -1485,6 +1485,17 @@
CallInst::Create(trackInitInst, Args.begin(), Args.end(), "", I);
return true;
}
+ } else if (F->getNameStr() == std::string("getrusage")) {
+ CastInst *BCI = BitCastInst::CreatePointerCast(I->getOperand(2), VoidPtrTy, "", I);
+ assert (isa<PointerType>(I->getOperand(2)->getType()));
+ const PointerType * PT = cast<PointerType>(I->getOperand(2)->getType());
+ const Type * ET = PT->getElementType();
+ Value * AllocSize = ConstantInt::get(Int64Ty, TD->getTypeAllocSize(ET));
+ std::vector<Value *>Args;
+ Args.push_back(BCI);
+ Args.push_back(AllocSize);
+ Args.push_back(getTagCounter());
+ CallInst::Create(trackInitInst, Args.begin(), Args.end(), "", I);
} else if (F->getNameStr() == std::string("__ctype_b_loc")) {
CastInst *BCI = BitCastInst::CreatePointerCast(I, VoidPtrTy);
BCI->insertAfter(I);
@@ -1512,6 +1523,13 @@
Constant *F = M.getOrInsertFunction("trackctype_32", VoidTy, VoidPtrTy, Int32Ty, NULL);
CallInst *CI = CallInst::Create(F, Args.begin(), Args.end());
CI->insertAfter(BCI);
+ } else if (F->getNameStr() == std::string("strcat")) {
+ std::vector<Value *> Args;
+ Args.push_back(I->getOperand(1));
+ Args.push_back(I->getOperand(2));
+ Args.push_back(getTagCounter());
+ Constant *F = M.getOrInsertFunction("trackStrcatInst", VoidTy, VoidPtrTy, VoidPtrTy, Int32Ty, NULL);
+ CallInst::Create(F, Args.begin(), Args.end(), "", I);
} else if (F->getNameStr() == std::string("strcpy")) {
std::vector<Value *> Args;
Args.push_back(I->getOperand(1));
Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c?rev=132932&r1=132931&r2=132932&view=diff
==============================================================================
--- poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c (original)
+++ poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Mon Jun 13 16:02:05 2011
@@ -246,3 +246,9 @@
void trackStrcpyInst(void *dst, void *src, uint32_t tag) {
copyTypeInfo(dst, src, strlen(src)+1, tag);
}
+
+void trackStrcatInst(void *dst, void *src, uint32_t tag) {
+ uintptr_t dst_start = (uintptr_t)(dst) + strlen(dst) -1;
+ copyTypeInfo((void*)dst_start, src, strlen(src)+1, tag);
+}
+
More information about the llvm-commits
mailing list