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

Arushi Aggarwal aggarwa4 at illinois.edu
Thu Jun 2 09:58:43 PDT 2011


Author: aggarwa4
Date: Thu Jun  2 11:58:43 2011
New Revision: 132463

URL: http://llvm.org/viewvc/llvm-project?rev=132463&view=rev
Log:
Instead of passing the number of varargs, pass the number of
total arguments. Each function, then subtracts the number of
fixed arguments in its signature. Hence, the callee need not
know the number of fixed args.

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=132463&r1=132462&r2=132463&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Thu Jun  2 11:58:43 2011
@@ -483,7 +483,14 @@
   inst_iterator InsPt = inst_begin(NewF);
   Function::arg_iterator NII = NewF->arg_begin();
   AllocaInst *VASizeLoc = new AllocaInst(Int64Ty, "", &*InsPt);
-  new StoreInst(NII, VASizeLoc, &*InsPt);
+  // Subtract the number of initial arguments
+  Constant *InitialArgs = ConstantInt::get(Int64Ty, F.arg_size());
+  Instruction *NewValue = BinaryOperator::Create(BinaryOperator::Sub,
+                                                 NII,
+                                                 InitialArgs,
+                                                 "varargs",
+                                                 &*InsPt);
+  new StoreInst(NewValue, VASizeLoc, &*InsPt);
   NII++;
   AllocaInst *VAMDLoc = new AllocaInst(VoidPtrTy, "", &*InsPt);
   new StoreInst(NII, VAMDLoc, &*InsPt);
@@ -548,7 +555,6 @@
     }
   }
 
-  assert(VAStart && "Varargs function without a call to VAStart???");
   // modify calls to va list functions to pass the metadata
   for (Function::iterator B = NewF->begin(), FE = NewF->end(); B != FE; ++B) {
     for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) {
@@ -585,9 +591,9 @@
       continue;
     std::vector<Value *> Args;
     unsigned int i;
-    unsigned int NumVarArgs = CI->getNumOperands() - F.arg_size() - 1;
-    Value *NumArgs = ConstantInt::get(Int32Ty, NumVarArgs);
-    AllocaInst *AI = new AllocaInst(Int8Ty, NumArgs, "", CI);
+    unsigned int NumArgs = CI->getNumOperands() - 1;
+    Value *NumArgsVal = ConstantInt::get(Int32Ty, NumArgs);
+    AllocaInst *AI = new AllocaInst(Int8Ty, NumArgsVal, "", CI);
     // set the metadata for the varargs in AI
     unsigned int j =0;
     for(i = F.arg_size() + 1; i <CI->getNumOperands(); i++) {
@@ -604,10 +610,9 @@
     }
 
     // As the first argument pass the number of var_arg arguments
-    Args.push_back(ConstantInt::get(Int64Ty, NumVarArgs));
+    Args.push_back(ConstantInt::get(Int64Ty, NumArgs));
     Args.push_back(AI);
     for(i = 1 ;i < CI->getNumOperands(); i++) {
-      CI->getOperand(i)->dump();
       // Add the original argument
       Args.push_back(CI->getOperand(i));
     }





More information about the llvm-commits mailing list