[llvm-commits] [poolalloc] r75819 - in /poolalloc/trunk/lib/PoolAllocate: PAMultipleGlobalPool.cpp PASimple.cpp PointerCompress.cpp PoolAllocate.cpp TransformFunctionBody.cpp
John Criswell
criswell at uiuc.edu
Wed Jul 15 13:06:20 PDT 2009
Author: criswell
Date: Wed Jul 15 15:06:20 2009
New Revision: 75819
URL: http://llvm.org/viewvc/llvm-project?rev=75819&view=rev
Log:
Partial update to the new LLVM API.
Use the LLVMContext to add integer constants.
Modified:
poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp
poolalloc/trunk/lib/PoolAllocate/PASimple.cpp
poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp
poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
Modified: poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp?rev=75819&r1=75818&r2=75819&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PAMultipleGlobalPool.cpp Wed Jul 15 15:06:20 2009
@@ -139,7 +139,7 @@
Value * AllocSize;
if (MI->isArrayAllocation()) {
Value * NumElements = MI->getArraySize();
- Value * ElementSize = ConstantInt::get (Type::Int32Ty,
+ Value * ElementSize = Context->getConstantInt (Type::Int32Ty,
TD.getTypeAllocSize(MI->getAllocatedType()));
AllocSize = BinaryOperator::Create (Instruction::Mul,
ElementSize,
@@ -147,7 +147,7 @@
"sizetmp",
MI);
} else {
- AllocSize = ConstantInt::get (Type::Int32Ty,
+ AllocSize = Context->getConstantInt (Type::Int32Ty,
TD.getTypeAllocSize(MI->getAllocatedType()));
}
@@ -368,8 +368,8 @@
ConstantAggregateZero::get(getPoolType()),
"__poolalloc_GlobalPool");
- Value *ElSize = ConstantInt::get(Type::Int32Ty, RecSize);
- Value *AlignV = ConstantInt::get(Type::Int32Ty, Align);
+ Value *ElSize = Context->getConstantInt(Type::Int32Ty, RecSize);
+ Value *AlignV = Context->getConstantInt(Type::Int32Ty, Align);
Value* Opts[3] = {GV, ElSize, AlignV};
CallInst::Create(PoolInit, Opts, Opts + 3, "", InsertAtEnd);
Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=75819&r1=75818&r2=75819&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Wed Jul 15 15:06:20 2009
@@ -179,7 +179,7 @@
Value * AllocSize;
if (MI->isArrayAllocation()) {
Value * NumElements = MI->getArraySize();
- Value * ElementSize = ConstantInt::get (Type::Int32Ty,
+ Value * ElementSize = Context->getConstantInt (Type::Int32Ty,
TD.getTypeAllocSize(MI->getAllocatedType()));
AllocSize = BinaryOperator::Create (Instruction::Mul,
ElementSize,
@@ -187,7 +187,7 @@
"sizetmp",
MI);
} else {
- AllocSize = ConstantInt::get (Type::Int32Ty,
+ AllocSize = Context->getConstantInt (Type::Int32Ty,
TD.getTypeAllocSize(MI->getAllocatedType()));
}
@@ -363,8 +363,8 @@
GlobalValue::ExternalLinkage, "__poolalloc_init", &M);
BasicBlock * BB = BasicBlock::Create("entry", InitFunc);
- Value *ElSize = ConstantInt::get(Type::Int32Ty, RecSize);
- Value *AlignV = ConstantInt::get(Type::Int32Ty, Align);
+ Value *ElSize = Context->getConstantInt(Type::Int32Ty, RecSize);
+ Value *AlignV = Context->getConstantInt(Type::Int32Ty, Align);
Value* Opts[3] = {GV, ElSize, AlignV};
CallInst::Create(PoolInit, Opts, Opts + 3, "", BB);
Modified: poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp?rev=75819&r1=75818&r2=75819&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp Wed Jul 15 15:06:20 2009
@@ -287,7 +287,7 @@
assert(PoolBase == 0 && "Mixing and matching optimized vs not!");
// Get the pool base pointer.
- Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
+ Constant *Zero = getGlobalContext().getConstantInt(Type::Int32Ty, 0);
Value *Opts[2] = {Zero, Zero};
Value *BasePtrPtr = GetElementPtrInst::Create(getPoolDesc(), Opts, Opts + 2,
"poolbaseptrptr", &I);
@@ -299,7 +299,7 @@
isa<GlobalVariable>(PoolDesc))) {
BasicBlock::iterator IP = I.getParent()->getParent()->begin()->begin();
while (isa<AllocaInst>(IP)) ++IP;
- Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
+ Constant *Zero = getGlobalContext().getConstantInt(Type::Int32Ty, 0);
Value *Opts[2] = {Zero, Zero};
Value *BasePtrPtr = GetElementPtrInst::Create(getPoolDesc(), Opts, Opts + 2,
"poolbaseptrptr", IP);
@@ -383,7 +383,7 @@
/// value, creating a new forward ref value as needed.
Value *getTransformedValue(Value *V) {
if (isa<ConstantPointerNull>(V)) // null -> uint 0
- return ConstantInt::get(SCALARUINTTYPE, 0);
+ return getGlobalContext().getConstantInt(SCALARUINTTYPE, 0);
if (isa<UndefValue>(V)) // undef -> uint undef
return UndefValue::get(SCALARUINTTYPE);
@@ -713,7 +713,7 @@
if (Field) {
uint64_t FieldOffs = TD.getStructLayout(cast<StructType>(NTy))
->getElementOffset(Field);
- Constant *FieldOffsCst = ConstantInt::get(SCALARUINTTYPE, FieldOffs);
+ Constant *FieldOffsCst = getGlobalContext().getConstantInt(SCALARUINTTYPE, FieldOffs);
Val = BinaryOperator::CreateAdd(Val, FieldOffsCst,
GEPI.getName(), &GEPI);
}
@@ -732,7 +732,7 @@
if (Idx->getType() != SCALARUINTTYPE)
Idx = CastInst::CreateSExtOrBitCast(Idx, SCALARUINTTYPE, Idx->getName(), &GEPI);
- Constant *Scale = ConstantInt::get(SCALARUINTTYPE,
+ Constant *Scale = getGlobalContext().getConstantInt(SCALARUINTTYPE,
TD.getTypeAllocSize(ElTy));
Idx = BinaryOperator::CreateMul(Idx, Scale, "fieldidx", &GEPI);
Val = BinaryOperator::CreateAdd(Val, Idx, GEPI.getName(), &GEPI);
@@ -828,7 +828,7 @@
}
} else {
// FIXME: This assumes that all null pointers are compressed!
- SrcVal = ConstantInt::get(MEMUINTTYPE, 0);
+ SrcVal = getGlobalContext().getConstantInt(MEMUINTTYPE, 0);
}
// Get the pool base pointer.
@@ -862,11 +862,11 @@
std::vector<Value*> Ops;
Ops.push_back(CI.getOperand(1));
// Transform to pass in the compressed size.
- Ops.push_back(ConstantInt::get(Type::Int32Ty, PI->getNewSize()));
+ Ops.push_back(getGlobalContext().getConstantInt(Type::Int32Ty, PI->getNewSize()));
// Pointer compression can reduce the alignment restriction to 4 bytes from 8.
// Reevaluate the desired alignment.
- Ops.push_back(ConstantInt::get(Type::Int32Ty,
+ Ops.push_back(getGlobalContext().getConstantInt(Type::Int32Ty,
PA::Heuristic::getRecommendedAlignment(PI->getNewType(), TD)));
// TODO: Compression could reduce the alignment restriction for the pool!
Value *PB = CallInst::Create(PtrComp.PoolInitPC, Ops.begin(), Ops.end(), "", &CI);
@@ -901,11 +901,11 @@
if (OldSizeV != PI->getNewSize()) {
// Emit code to scale the allocated size down by the old size then up by
// the new size. We actually compute (N+OS-1)/OS * NS.
- Value *OldSize = ConstantInt::get(Type::Int32Ty, OldSizeV);
- Value *NewSize = ConstantInt::get(Type::Int32Ty, PI->getNewSize());
+ Value *OldSize = getGlobalContext().getConstantInt(Type::Int32Ty, OldSizeV);
+ Value *NewSize = getGlobalContext().getConstantInt(Type::Int32Ty, PI->getNewSize());
Size = BinaryOperator::CreateAdd(Size,
- ConstantInt::get(Type::Int32Ty, OldSizeV-1),
+ getGlobalContext().getConstantInt(Type::Int32Ty, OldSizeV-1),
"roundup", &CI);
Size = BinaryOperator::CreateUDiv(Size, OldSize, "numnodes", &CI);
Size = BinaryOperator::CreateMul(Size, NewSize, "newbytes", &CI);
Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=75819&r1=75818&r2=75819&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Wed Jul 15 15:06:20 2009
@@ -288,7 +288,16 @@
Calls.push_back(cast<CallInst>(*UI));
}
-static void OptimizePointerNotNull(Value *V) {
+//
+// Function: OptimizePointerNotNull()
+//
+// Inputs:
+// V - ???
+// Context - The LLVM Context to which any values we insert into the program
+// will belong.
+//
+static void
+OptimizePointerNotNull(Value *V, LLVMContext * Context) {
for (Value::use_iterator I = V->use_begin(), E = V->use_end(); I != E; ++I) {
Instruction *User = cast<Instruction>(*I);
if (isa<ICmpInst>(User) && cast<ICmpInst>(User)->isEquality()) {
@@ -296,7 +305,7 @@
if (isa<Constant>(User->getOperand(1)) &&
cast<Constant>(User->getOperand(1))->isNullValue()) {
bool CondIsTrue = ICI->getPredicate() == ICmpInst::ICMP_NE;
- User->replaceAllUsesWith(ConstantInt::get(Type::Int1Ty, CondIsTrue));
+ User->replaceAllUsesWith(Context->getConstantInt(Type::Int1Ty, CondIsTrue));
}
} else if ((User->getOpcode() == Instruction::Trunc) ||
(User->getOpcode() == Instruction::ZExt) ||
@@ -312,10 +321,10 @@
(User->getOpcode() == Instruction::BitCast)) {
// Casted pointers are also not null.
if (isa<PointerType>(User->getType()))
- OptimizePointerNotNull(User);
+ OptimizePointerNotNull(User, Context);
} else if (User->getOpcode() == Instruction::GetElementPtr) {
// GEP'd pointers are also not null.
- OptimizePointerNotNull(User);
+ OptimizePointerNotNull(User, Context);
}
}
}
@@ -331,7 +340,7 @@
CallInst *CI = Calls[i];
// poolalloc never returns null. Loop over all uses of the call looking for
// set(eq|ne) X, null.
- OptimizePointerNotNull(CI);
+ OptimizePointerNotNull(CI, Context);
}
// TODO: poolfree accepts a null pointer, so remove any check above it, like
@@ -619,8 +628,8 @@
while (isa<AllocaInst>(InsertPt)) ++InsertPt;
}
- Value *ElSize = ConstantInt::get(Type::Int32Ty, RecSize);
- Value *AlignV = ConstantInt::get(Type::Int32Ty, Align);
+ Value *ElSize = Context->getConstantInt(Type::Int32Ty, RecSize);
+ Value *AlignV = Context->getConstantInt(Type::Int32Ty, Align);
Value* Opts[3] = {GV, ElSize, AlignV};
CallInst::Create(PoolInit, Opts, Opts + 3, "", InsertPt);
++NumPools;
@@ -950,9 +959,9 @@
// Insert the calls to initialize the pool.
unsigned ElSizeV = Heuristic::getRecommendedSize(Node);
- Value *ElSize = ConstantInt::get(Type::Int32Ty, ElSizeV);
+ Value *ElSize = Context->getConstantInt(Type::Int32Ty, ElSizeV);
unsigned AlignV = Heuristic::getRecommendedAlignment(Node);
- Value *Align = ConstantInt::get(Type::Int32Ty, AlignV);
+ Value *Align = Context->getConstantInt(Type::Int32Ty, AlignV);
for (unsigned i = 0, e = PoolInitPoints.size(); i != e; ++i) {
Value* Opts[3] = {PD, ElSize, Align};
Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=75819&r1=75818&r2=75819&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Wed Jul 15 15:06:20 2009
@@ -215,8 +215,8 @@
if (PH == 0 || isa<ConstantPointerNull>(PH)) return;
TargetData &TD = PAInfo.getAnalysis<TargetData>();
- Value *AllocSize =
- ConstantInt::get(Type::Int32Ty, TD.getTypeAllocSize(MI.getAllocatedType()));
+ Value *AllocSize = getGlobalContext().getConstantInt(Type::Int32Ty,
+ TD.getTypeAllocSize(MI.getAllocatedType()));
if (MI.isArrayAllocation())
AllocSize = BinaryOperator::Create(Instruction::Mul, AllocSize,
@@ -273,8 +273,7 @@
Value *PH = getPoolHandle(&MI);
if (PH == 0 || isa<ConstantPointerNull>(PH)) return;
TargetData &TD = PAInfo.getAnalysis<TargetData>();
- Value *AllocSize =
- ConstantInt::get(Type::Int32Ty, TD.getTypeAllocSize(MI.getAllocatedType()));
+ Value *AllocSize = getGlobalContext().getConstantInt(Type::Int32Ty, TD.getTypeAllocSize(MI.getAllocatedType()));
if (MI.isArrayAllocation())
AllocSize = BinaryOperator::Create(Instruction::Mul, AllocSize,
@@ -368,8 +367,8 @@
BBI);
// We know that the memory returned by poolalloc is at least 4 byte aligned.
- Value* Opts[4] = {Ptr, ConstantInt::get(Type::Int8Ty, 0),
- V2, ConstantInt::get(Type::Int32Ty, 4)};
+ Value* Opts[4] = {Ptr, getGlobalContext().getConstantInt(Type::Int8Ty, 0),
+ V2, getGlobalContext().getConstantInt(Type::Int32Ty, 4)};
CallInst::Create(MemSet, Opts, Opts + 4, "", BBI);
}
@@ -741,8 +740,8 @@
// escapes
BasicBlock::iterator InsertPt = TheCall->getParent()->getParent()->front().begin();
ArgVal = new AllocaInst(PAInfo.getPoolType(), 0, "PD", InsertPt);
- Value *ElSize = ConstantInt::get(Type::Int32Ty,0);
- Value *Align = ConstantInt::get(Type::Int32Ty,0);
+ Value *ElSize = getGlobalContext().getConstantInt(Type::Int32Ty,0);
+ Value *Align = getGlobalContext().getConstantInt(Type::Int32Ty,0);
Value* Opts[3] = {ArgVal, ElSize, Align};
CallInst::Create(PAInfo.PoolInit, Opts, Opts + 3,"", TheCall);
BasicBlock::iterator BBI = TheCall;
More information about the llvm-commits
mailing list