[llvm-commits] [poolalloc] r131892 - in /poolalloc/trunk: lib/AssistDS/TypeChecks.cpp runtime/DynamicTypeChecks/TypeRuntime.c
Arushi Aggarwal
aggarwa4 at illinois.edu
Sun May 22 18:27:52 PDT 2011
Author: aggarwa4
Date: Sun May 22 20:27:52 2011
New Revision: 131892
URL: http://llvm.org/viewvc/llvm-project?rev=131892&view=rev
Log:
It is not necessary to make a copy of argv, only
to initialize the meta data. This also means we
do not instrument all uses of argv.
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=131892&r1=131891&r2=131892&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Sun May 22 20:27:52 2011
@@ -666,27 +666,11 @@
Value *Argv = ++AI;
Instruction *InsertPt = MainFunc.front().begin();
- Constant * RegisterArgv = M.getOrInsertFunction("trackArgvType", VoidPtrTy, Argc->getType(), Argv->getType(), NULL);
+ Constant * RegisterArgv = M.getOrInsertFunction("trackArgvType", VoidTy, Argc->getType(), Argv->getType(), NULL);
std::vector<Value *> fargs;
fargs.push_back (Argc);
fargs.push_back (Argv);
- CallInst *CI = CallInst::Create (RegisterArgv, fargs.begin(), fargs.end(), "", InsertPt);
- CastInst *BCII = BitCastInst::CreatePointerCast(CI, Argv->getType());
- BCII->insertAfter(CI);
- std::vector<User *> Uses;
- Value::use_iterator UI = Argv->use_begin();
- for (; UI != Argv->use_end(); ++UI) {
- if (Instruction * Use = dyn_cast<Instruction>(UI))
- if (CI != Use) {
- Uses.push_back (*UI);
- }
- }
-
- while (Uses.size()) {
- User *Use = Uses.back();
- Uses.pop_back();
- Use->replaceUsesOfWith (Argv, BCII);
- }
+ CallInst::Create (RegisterArgv, fargs.begin(), fargs.end(), "", InsertPt);
return true;
}
Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c?rev=131892&r1=131891&r2=131892&view=diff
==============================================================================
--- poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c (original)
+++ poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Sun May 22 20:27:52 2011
@@ -65,23 +65,12 @@
* Copy arguments into a new array, and initialize
* metadata for that location to TOP/initialized.
*/
-void * trackArgvType(int argc, char **argv) {
-
- char ** argv_temp = (char **)malloc((sizeof(char*)*(argc+1)));
+void trackArgvType(int argc, char **argv) {
int index = 0;
for (; index < argc; ++index) {
- char *argv_index_temp =
- (char *)malloc((strlen(argv[index])+ 1)*sizeof(char));
- argv_index_temp = strcpy(argv_index_temp, argv[index]);
-
- trackInitInst(argv_index_temp, (strlen(argv[index]) + 1)*sizeof(char), 0);
- argv_temp[index] = argv_index_temp;
+ trackInitInst(argv[index], (strlen(argv[index]) + 1)*sizeof(char), 0);
}
- argv_temp[argc] = NULL;
-
- trackInitInst(argv_temp, (argc + 1)*sizeof(char*), 0);
-
- return (void*)argv_temp;
+ trackInitInst(argv, (argc + 1)*sizeof(char*), 0);
}
/**
More information about the llvm-commits
mailing list