[llvm-commits] [poolalloc] r130260 - /poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Tue Apr 26 17:10:28 PDT 2011
Author: aggarwa4
Date: Tue Apr 26 19:10:28 2011
New Revision: 130260
URL: http://llvm.org/viewvc/llvm-project?rev=130260&view=rev
Log:
1. Only do replacement for arguments that are
actually being used in the function.
2. If a gep is passed in as multiple arguments, do the
transform only once.
Modified:
poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp
Modified: poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp?rev=130260&r1=130259&r2=130260&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp Tue Apr 26 19:10:28 2011
@@ -56,19 +56,23 @@
continue;
// find the argument we must replace
+ Function::arg_iterator ai = F->arg_begin(), ae = F->arg_end();
unsigned argNum = 1;
- for(; argNum < CI->getNumOperands();argNum++) {
+ for(; argNum < CI->getNumOperands();argNum++, ++ai) {
+ if(ai->use_empty())
+ continue;
if (isa<GEPOperator>(CI->getOperand(argNum)))
break;
}
-
- if(argNum == CI->getNumOperands())
+
+ // if no argument was a GEP operator to be changed
+ if(ai == ae)
continue;
+
GEPOperator *GEP = dyn_cast<GEPOperator>(CI->getOperand(argNum));
if(!GEP->hasAllConstantIndices())
continue;
-
// Construct the new Type
// Appends the struct Type at the beginning
std::vector<const Type*>TP;
@@ -81,7 +85,7 @@
const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false);
Function *NewF;
numSimplified++;
- if(numSimplified > 25) //26
+ if(numSimplified > 1000)
return true;
NewF = Function::Create(NewFTy,
@@ -119,6 +123,11 @@
Indices.append(GEP->op_begin()+1, GEP->op_end());
GetElementPtrInst *GEP_new = GetElementPtrInst::Create(cast<Value>(NI), Indices.begin(), Indices.end(), "", InsertPoint);
fargs.at(argNum)->replaceAllUsesWith(GEP_new);
+ unsigned j = argNum + 1;
+ for(; j < CI->getNumOperands();j++) {
+ if(CI->getOperand(j) == GEP)
+ fargs.at(j)->replaceAllUsesWith(GEP_new);
+ }
SmallVector<Value*, 8> Args;
Args.push_back(GEP->getPointerOperand());
More information about the llvm-commits
mailing list