[llvm-commits] [poolalloc] r132820 - /poolalloc/trunk/lib/AssistDS/TypeChecks.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Thu Jun 9 16:41:30 PDT 2011


Author: aggarwa4
Date: Thu Jun  9 18:41:30 2011
New Revision: 132820

URL: http://llvm.org/viewvc/llvm-project?rev=132820&view=rev
Log:
Do not insert AllocaInst's just anywhere. They
could be inside loops. Move to function header.

Thanks to SAFECode for pointing this out!

Modified:
    poolalloc/trunk/lib/AssistDS/TypeChecks.cpp

Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=132820&r1=132819&r2=132820&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Thu Jun  9 18:41:30 2011
@@ -642,8 +642,9 @@
     std::vector<Value *> Args;
     unsigned int i;
     unsigned int NumArgs = CI->getNumOperands() - 1;
+    inst_iterator InsPt = inst_begin(CI->getParent()->getParent());
     Value *NumArgsVal = ConstantInt::get(Int32Ty, NumArgs);
-    AllocaInst *AI = new AllocaInst(Int8Ty, NumArgsVal, "", CI);
+    AllocaInst *AI = new AllocaInst(Int8Ty, NumArgsVal, "", &*InsPt);
     // set the metadata for the varargs in AI
     for(i = 1; i <CI->getNumOperands(); i++) {
       Value *Idx[2];
@@ -877,10 +878,11 @@
     if(!CI)
       continue;
     std::vector<Value *> Args;
+    inst_iterator InsPt = inst_begin(CI->getParent()->getParent());
     unsigned int i;
     unsigned int NumArgs = CI->getNumOperands() - 1;
     Value *NumArgsVal = ConstantInt::get(Int32Ty, NumArgs);
-    AllocaInst *AI = new AllocaInst(Int8Ty, NumArgsVal, "", CI);
+    AllocaInst *AI = new AllocaInst(Int8Ty, NumArgsVal, "", &*CI);
     // set the metadata for the varargs in AI
     for(i = 1; i <CI->getNumOperands(); i++) {
       Value *Idx[2];
@@ -1544,7 +1546,8 @@
   unsigned int NumArgs = I->getNumOperands() - 1;
   Value *NumArgsVal = ConstantInt::get(Int32Ty, NumArgs);
 
-  AllocaInst *AI = new AllocaInst(Int8Ty, NumArgsVal, "", I);
+  inst_iterator InsPt = inst_begin(I->getParent()->getParent());
+  AllocaInst *AI = new AllocaInst(Int8Ty, NumArgsVal, "", &*InsPt);
   for(unsigned int i = 1; i < I->getNumOperands(); i++) {
     Value *Idx[2];
     Idx[0] = ConstantInt::get(Int32Ty, i-1);





More information about the llvm-commits mailing list