[llvm-commits] [poolalloc] r137093 - in /poolalloc/trunk: include/assistDS/SimplifyGEP.h include/assistDS/SimplifyInsertValue.h include/assistDS/SimplifyLoad.h include/assistDS/StructReturnToPointer.h lib/AssistDS/SimplifyGEP.cpp lib/AssistDS/SimplifyInsertValue.cpp lib/AssistDS/SimplifyLoad.cpp lib/AssistDS/StructReturnToPointer.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Mon Aug 8 17:58:33 PDT 2011
Author: aggarwa4
Date: Mon Aug 8 19:58:33 2011
New Revision: 137093
URL: http://llvm.org/viewvc/llvm-project?rev=137093&view=rev
Log:
Move to mainline
Modified:
poolalloc/trunk/include/assistDS/SimplifyGEP.h
poolalloc/trunk/include/assistDS/SimplifyInsertValue.h
poolalloc/trunk/include/assistDS/SimplifyLoad.h
poolalloc/trunk/include/assistDS/StructReturnToPointer.h
poolalloc/trunk/lib/AssistDS/SimplifyGEP.cpp
poolalloc/trunk/lib/AssistDS/SimplifyInsertValue.cpp
poolalloc/trunk/lib/AssistDS/SimplifyLoad.cpp
poolalloc/trunk/lib/AssistDS/StructReturnToPointer.cpp
Modified: poolalloc/trunk/include/assistDS/SimplifyGEP.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/SimplifyGEP.h?rev=137093&r1=137092&r2=137093&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/SimplifyGEP.h (original)
+++ poolalloc/trunk/include/assistDS/SimplifyGEP.h Mon Aug 8 19:58:33 2011
@@ -25,7 +25,7 @@
TargetData * TD;
public:
static char ID;
- SimplifyGEP() : ModulePass(&ID) {}
+ SimplifyGEP() : ModulePass(ID) {}
virtual bool runOnModule(Module& M);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<TargetData>();
Modified: poolalloc/trunk/include/assistDS/SimplifyInsertValue.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/SimplifyInsertValue.h?rev=137093&r1=137092&r2=137093&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/SimplifyInsertValue.h (original)
+++ poolalloc/trunk/include/assistDS/SimplifyInsertValue.h Mon Aug 8 19:58:33 2011
@@ -23,7 +23,7 @@
class SimplifyIV : public ModulePass {
public:
static char ID;
- SimplifyIV() : ModulePass(&ID) {}
+ SimplifyIV() : ModulePass(ID) {}
virtual bool runOnModule(Module& M);
};
}
Modified: poolalloc/trunk/include/assistDS/SimplifyLoad.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/SimplifyLoad.h?rev=137093&r1=137092&r2=137093&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/SimplifyLoad.h (original)
+++ poolalloc/trunk/include/assistDS/SimplifyLoad.h Mon Aug 8 19:58:33 2011
@@ -22,7 +22,7 @@
class SimplifyLoad : public ModulePass {
public:
static char ID;
- SimplifyLoad() : ModulePass(&ID) {}
+ SimplifyLoad() : ModulePass(ID) {}
virtual bool runOnModule(Module& M);
};
}
Modified: poolalloc/trunk/include/assistDS/StructReturnToPointer.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/StructReturnToPointer.h?rev=137093&r1=137092&r2=137093&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/StructReturnToPointer.h (original)
+++ poolalloc/trunk/include/assistDS/StructReturnToPointer.h Mon Aug 8 19:58:33 2011
@@ -23,7 +23,7 @@
class StructRet : public ModulePass {
public:
static char ID;
- StructRet() : ModulePass(&ID) {}
+ StructRet() : ModulePass(ID) {}
virtual bool runOnModule(Module& M);
};
}
Modified: poolalloc/trunk/lib/AssistDS/SimplifyGEP.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/SimplifyGEP.cpp?rev=137093&r1=137092&r2=137093&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/SimplifyGEP.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/SimplifyGEP.cpp Mon Aug 8 19:58:33 2011
@@ -107,8 +107,7 @@
// -> GEP i8* X, ...
SmallVector<Value*, 8> Idx(GEP->idx_begin()+1, GEP->idx_end());
GetElementPtrInst *Res =
- GetElementPtrInst::Create(StrippedPtr, Idx.begin(),
- Idx.end(), GEP->getName(), GEP);
+ GetElementPtrInst::Create(StrippedPtr, Idx, GEP->getName(), GEP);
Res->setIsInBounds(GEP->isInBounds());
GEP->replaceAllUsesWith(Res);
continue;
@@ -132,8 +131,8 @@
// Transform things like:
// %t = getelementptr i32* bitcast ([2 x i32]* %str to i32*), i32 %V
// into: %t1 = getelementptr [2 x i32]* %str, i32 0, i32 %V; bitcast
- const Type *SrcElTy = StrippedPtrTy->getElementType();
- const Type *ResElTy=cast<PointerType>(PtrOp->getType())->getElementType();
+ Type *SrcElTy = StrippedPtrTy->getElementType();
+ Type *ResElTy=cast<PointerType>(PtrOp->getType())->getElementType();
if (TD && SrcElTy->isArrayTy() &&
TD->getTypeAllocSize(cast<ArrayType>(SrcElTy)->getElementType()) ==
TD->getTypeAllocSize(ResElTy)) {
@@ -141,7 +140,7 @@
Idx[0] = Constant::getNullValue(Type::getInt32Ty(GEP->getContext()));
Idx[1] = GEP->getOperand(1);
Value *NewGEP = GetElementPtrInst::Create(StrippedPtr, Idx,
- Idx+2, GEP->getName(), GEP);
+ GEP->getName(), GEP);
// V and GEP are both pointer types --> BitCast
GEP->replaceAllUsesWith(new BitCastInst(NewGEP, GEP->getType(), GEP->getName(), GEP));
continue;
@@ -200,7 +199,7 @@
Idx[0] = Constant::getNullValue(Type::getInt32Ty(GEP->getContext()));
Idx[1] = NewIdx;
Value *NewGEP = GetElementPtrInst::Create(StrippedPtr, Idx,
- Idx+2, GEP->getName(), GEP);
+ GEP->getName(), GEP);
GEP->replaceAllUsesWith(new BitCastInst(NewGEP, GEP->getType(), GEP->getName(), GEP));
continue;
}
Modified: poolalloc/trunk/lib/AssistDS/SimplifyInsertValue.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/SimplifyInsertValue.cpp?rev=137093&r1=137092&r2=137093&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/SimplifyInsertValue.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/SimplifyInsertValue.cpp Mon Aug 8 19:58:33 2011
@@ -63,7 +63,7 @@
if(IV->getNumUses() != 1)
continue;
// Check that its only use is a StoreInst
- StoreInst *SI = dyn_cast<StoreInst>(IV->use_begin());
+ StoreInst *SI = dyn_cast<StoreInst>(*(IV->use_begin()));
if(!SI)
continue;
// Check that it is the stored value
@@ -74,14 +74,14 @@
do {
// replace by a series of gep/stores
SmallVector<Value*, 8> Indices;
- const Type *Int32Ty = Type::getInt32Ty(M.getContext());
+ Type *Int32Ty = Type::getInt32Ty(M.getContext());
Indices.push_back(Constant::getNullValue(Int32Ty));
for (InsertValueInst::idx_iterator I = IV->idx_begin(), E = IV->idx_end();
I != E; ++I) {
Indices.push_back(ConstantInt::get(Int32Ty, *I));
}
- GetElementPtrInst *GEP = GetElementPtrInst::CreateInBounds(SI->getOperand(1), Indices.begin(),
- Indices.end(), SI->getName(), SI) ;
+ GetElementPtrInst *GEP = GetElementPtrInst::CreateInBounds(SI->getOperand(1), Indices,
+ SI->getName(), SI) ;
new StoreInst(IV->getInsertedValueOperand(), GEP, SI);
IV = dyn_cast<InsertValueInst>(IV->getAggregateOperand());
Modified: poolalloc/trunk/lib/AssistDS/SimplifyLoad.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/SimplifyLoad.cpp?rev=137093&r1=137092&r2=137093&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/SimplifyLoad.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/SimplifyLoad.cpp Mon Aug 8 19:58:33 2011
@@ -57,7 +57,7 @@
if(!LI)
continue;
if(LI->getNumUses() == 1) {
- if(CastInst *CI = dyn_cast<CastInst>(LI->use_begin())) {
+ if(CastInst *CI = dyn_cast<CastInst>(*(LI->use_begin()))) {
if(LI->getType()->isPointerTy()) {
if(ConstantExpr *CE = dyn_cast<ConstantExpr>(LI->getOperand(0))) {
if(const PointerType *PTy = dyn_cast<PointerType>(CE->getOperand(0)->getType()))
Modified: poolalloc/trunk/lib/AssistDS/StructReturnToPointer.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/StructReturnToPointer.cpp?rev=137093&r1=137092&r2=137093&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/StructReturnToPointer.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/StructReturnToPointer.cpp Mon Aug 8 19:58:33 2011
@@ -17,6 +17,7 @@
#include "llvm/Attributes.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/ValueMap.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Debug.h"
@@ -60,23 +61,23 @@
while(!worklist.empty()) {
Function *F = worklist.back();
worklist.pop_back();
- const Type *NewArgType = F->getReturnType()->getPointerTo();
+ Type *NewArgType = F->getReturnType()->getPointerTo();
// Construct the new Type
- std::vector<const Type*>TP;
+ std::vector<Type*>TP;
TP.push_back(NewArgType);
for (Function::arg_iterator ii = F->arg_begin(), ee = F->arg_end();
ii != ee; ++ii) {
TP.push_back(ii->getType());
}
- const FunctionType *NFTy = FunctionType::get(F->getReturnType(), TP, F->isVarArg());
+ FunctionType *NFTy = FunctionType::get(F->getReturnType(), TP, F->isVarArg());
// Create the new function body and insert it into the module.
Function *NF = Function::Create(NFTy,
GlobalValue::InternalLinkage,
F->getName(), &M);
- DenseMap<const Value*, Value*> ValueMap;
+ ValueToValueMapTy ValueMap;
Function::arg_iterator NI = NF->arg_begin();
NI->setName("ret");
++NI;
@@ -87,7 +88,7 @@
}
// Perform the cloning.
SmallVector<ReturnInst*,100> Returns;
- CloneFunctionInto(NF, F, ValueMap, Returns);
+ CloneFunctionInto(NF, F, ValueMap, false, Returns);
std::vector<Value*> fargs;
for(Function::arg_iterator ai = NF->arg_begin(),
ae= NF->arg_end(); ai != ae; ++ai) {
@@ -109,7 +110,7 @@
for(Value::use_iterator ui = F->use_begin(), ue = F->use_end();
ui != ue; ) {
- CallInst *CI = dyn_cast<CallInst>(ui++);
+ CallInst *CI = dyn_cast<CallInst>(*ui++);
if(!CI)
continue;
if(CI->getCalledFunction() != F)
@@ -143,7 +144,7 @@
AttrListPtr NewCallPAL = AttrListPtr::get(AttributesVec.begin(),
AttributesVec.end());
- CallInst *CallI = CallInst::Create(NF, Args.begin(), Args.end(), "", CI);
+ CallInst *CallI = CallInst::Create(NF, Args, "", CI);
CallI->setCallingConv(CI->getCallingConv());
CallI->setAttributes(NewCallPAL);
LoadInst *LI = new LoadInst(AllocaNew, "", CI);
More information about the llvm-commits
mailing list