[llvm-commits] [poolalloc] r131786 - in /poolalloc/trunk: lib/AssistDS/TypeChecks.cpp runtime/DynamicTypeChecks/TypeRuntime.c
Arushi Aggarwal
aggarwa4 at illinois.edu
Fri May 20 20:46:31 PDT 2011
Author: aggarwa4
Date: Fri May 20 22:46:31 2011
New Revision: 131786
URL: http://llvm.org/viewvc/llvm-project?rev=131786&view=rev
Log:
Propogate type info for strncpy.
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=131786&r1=131785&r2=131786&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Fri May 20 22:46:31 2011
@@ -923,6 +923,14 @@
Args.push_back(ConstantInt::get(Int32Ty, tagCounter++));
Constant *F = M.getOrInsertFunction("trackStrcpyInst", VoidTy, VoidPtrTy, VoidPtrTy, Int32Ty, NULL);
CallInst::Create(F, Args.begin(), Args.end(), "", I);
+ } else if (F->getNameStr() == std::string("strncpy")) {
+ std::vector<Value *>Args;
+ Args.push_back(I->getOperand(1));
+ Args.push_back(I->getOperand(2));
+ Args.push_back(I->getOperand(3));
+ Args.push_back(ConstantInt::get(Int32Ty, tagCounter++));
+ Constant *F = M.getOrInsertFunction("trackStrncpyInst", VoidTy, VoidPtrTy, VoidPtrTy, I->getOperand(3)->getType(), Int32Ty, NULL);
+ CallInst::Create(F, Args.begin(), Args.end(), "", I);
} else if(F->getNameStr() == std::string("ftime")) {
if(EnableTypeSafeOpt) {
if(TS->isTypeSafe(I->getOperand(1), I->getParent()->getParent())) {
Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c?rev=131786&r1=131785&r2=131786&view=diff
==============================================================================
--- poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c (original)
+++ poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Fri May 20 22:46:31 2011
@@ -206,6 +206,12 @@
trackInitInst(*(short**)ptr, sizeof(short)*384, tag);
}
+void trackStrncpyInst(void *dst, void *src, uint64_t size, uint32_t tag) {
+ if(strlen(src) < size)
+ size = strlen(src);
+ copyTypeInfo(dst, src, size, tag);
+}
+
void trackStrcpyInst(void *dst, void *src, uint32_t tag) {
copyTypeInfo(dst, src, strlen(src), tag);
}
More information about the llvm-commits
mailing list