[llvm-commits] [poolalloc] r126410 - /poolalloc/trunk/lib/AssistDS/MergeGEP.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Thu Feb 24 11:31:09 PST 2011
Author: aggarwa4
Date: Thu Feb 24 13:31:09 2011
New Revision: 126410
URL: http://llvm.org/viewvc/llvm-project?rev=126410&view=rev
Log:
Minor fixes. I believe a GEP Constant Expr, does
not return a pointer like a GEPInst does, hence copy
over all the indexes, into the new GEP.
Modified:
poolalloc/trunk/lib/AssistDS/MergeGEP.cpp
Modified: poolalloc/trunk/lib/AssistDS/MergeGEP.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/MergeGEP.cpp?rev=126410&r1=126409&r2=126410&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/MergeGEP.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/MergeGEP.cpp Thu Feb 24 13:31:09 2011
@@ -42,8 +42,8 @@
if(!(isa<GetElementPtrInst>(I)))
continue;
GetElementPtrInst *GEP = cast<GetElementPtrInst>(I);
- // if(!isa<ArrayType>(GEP->getType()->getElementType()))
- // continue;
+ if(!isa<ArrayType>(GEP->getType()->getElementType()))
+ continue;
std::vector<GetElementPtrInst*> worklist;
for (Value::use_iterator UI = GEP->use_begin(),
UE = GEP->use_end(); UI != UE; ++UI){
@@ -61,7 +61,7 @@
GetElementPtrInst *GEPNew = GetElementPtrInst::Create(GEP->getOperand(0),
Indices.begin(),
Indices.end(),
- GEPUse->getName()+ "mod",
+ GEPUse->getName()+ "moda",
GEPUse);
GEPUse->replaceAllUsesWith(GEPNew);
GEPUse->eraseFromParent();
@@ -75,31 +75,33 @@
for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE; I++) {
if(!(isa<GetElementPtrInst>(I)))
continue;
- GetElementPtrInst *GEP = cast<GetElementPtrInst>(I);
- if (Constant *C = dyn_cast<Constant>(GEP->getOperand(0))) {
+ GetElementPtrInst *GEP1 = cast<GetElementPtrInst>(I);
+ if(!isa<ArrayType>(GEP1->getType()->getElementType()))
+ continue;
+ if (Constant *C = dyn_cast<Constant>(GEP1->getOperand(0))) {
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
if (CE->getOpcode() == Instruction::GetElementPtr) {
- worklist.push_back(GEP);
+ worklist.push_back(GEP1);
}
}
}
}
}
while(!worklist.empty()) {
- GetElementPtrInst *GEP = worklist.back();
+ GetElementPtrInst *GEP1 = worklist.back();
worklist.pop_back();
- Constant *C = cast<Constant>(GEP->getOperand(0));
+ Constant *C = cast<Constant>(GEP1->getOperand(0));
ConstantExpr *CE = cast<ConstantExpr>(C);
SmallVector<Value*, 8> Indices;
Indices.append(CE->op_begin()+1, CE->op_end());
- Indices.append(GEP->idx_begin()+1, GEP->idx_end());
+ Indices.append(GEP1->idx_begin(), GEP1->idx_end());
GetElementPtrInst *GEPNew = GetElementPtrInst::Create(CE->getOperand(0),
Indices.begin(),
Indices.end(),
- GEP->getName()+ "mod",
- GEP);
- GEP->replaceAllUsesWith(GEPNew);
- GEP->eraseFromParent();
+ GEP1->getName()+ "modb",
+ GEP1);
+ GEP1->replaceAllUsesWith(GEPNew);
+ GEP1->eraseFromParent();
changed = true;
found = true;
}
More information about the llvm-commits
mailing list