aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/ExprTypeConvert.cpp37
-rw-r--r--lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp22
-rw-r--r--lib/Transforms/Instrumentation/TraceValues.cpp2
-rw-r--r--lib/Transforms/LevelRaise.cpp4
-rw-r--r--lib/Transforms/TransformInternals.cpp14
5 files changed, 37 insertions, 42 deletions
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index ab56c5270d..4abbbeb167 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -233,8 +233,8 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty,
const Type *BaseType = GEP->getPointerOperand()->getType();
const Type *ElTy = 0;
- while (!Indices.empty() && isa<ConstantUInt>(Indices.back()) &&
- cast<ConstantUInt>(Indices.back())->getValue() == 0) {
+ while (!Indices.empty() &&
+ Indices.back() == Constant::getNullValue(Indices.back()->getType())){
Indices.pop_back();
ElTy = GetElementPtrInst::getIndexedType(BaseType, Indices, true);
if (ElTy == PVTy)
@@ -245,11 +245,11 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty,
if (ElTy) break; // Found a number of zeros we can strip off!
// Otherwise, we can convert a GEP from one form to the other iff the
- // current gep is of the form 'getelementptr sbyte*, unsigned N
+ // current gep is of the form 'getelementptr sbyte*, long N
// and we could convert this to an appropriate GEP for the new type.
//
if (GEP->getNumOperands() == 2 &&
- GEP->getOperand(1)->getType() == Type::UIntTy &&
+ GEP->getOperand(1)->getType() == Type::LongTy &&
GEP->getType() == PointerType::get(Type::SByteTy)) {
// Do not Check to see if our incoming pointer can be converted
@@ -272,12 +272,12 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty,
}
// Otherwise, it could be that we have something like this:
- // getelementptr [[sbyte] *] * %reg115, uint %reg138 ; [sbyte]**
+ // getelementptr [[sbyte] *] * %reg115, long %reg138 ; [sbyte]**
// and want to convert it into something like this:
- // getelemenptr [[int] *] * %reg115, uint %reg138 ; [int]**
+ // getelemenptr [[int] *] * %reg115, long %reg138 ; [int]**
//
if (GEP->getNumOperands() == 2 &&
- GEP->getOperand(1)->getType() == Type::UIntTy &&
+ GEP->getOperand(1)->getType() == Type::LongTy &&
TD.getTypeSize(PTy->getElementType()) ==
TD.getTypeSize(GEP->getType()->getElementType())) {
const PointerType *NewSrcTy = PointerType::get(PVTy);
@@ -425,21 +425,20 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
const Type *BaseType = GEP->getPointerOperand()->getType();
const Type *PVTy = cast<PointerType>(Ty)->getElementType();
Res = 0;
- while (!Indices.empty() && isa<ConstantUInt>(Indices.back()) &&
- cast<ConstantUInt>(Indices.back())->getValue() == 0) {
+ while (!Indices.empty() &&
+ Indices.back() == Constant::getNullValue(Indices.back()->getType())){
Indices.pop_back();
if (GetElementPtrInst::getIndexedType(BaseType, Indices, true) == PVTy) {
- if (Indices.size() == 0) {
- Res = new CastInst(GEP->getPointerOperand(), BaseType); // NOOP
- } else {
+ if (Indices.size() == 0)
+ Res = new CastInst(GEP->getPointerOperand(), BaseType); // NOOP CAST
+ else
Res = new GetElementPtrInst(GEP->getPointerOperand(), Indices, Name);
- }
break;
}
}
if (Res == 0 && GEP->getNumOperands() == 2 &&
- GEP->getOperand(1)->getType() == Type::UIntTy &&
+ GEP->getOperand(1)->getType() == Type::LongTy &&
GEP->getType() == PointerType::get(Type::SByteTy)) {
// Otherwise, we can convert a GEP from one form to the other iff the
@@ -749,7 +748,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
//
if (DataSize != 1) {
TempScale = BinaryOperator::create(Instruction::Mul, Index,
- ConstantUInt::get(Type::UIntTy,
+ ConstantSInt::get(Type::LongTy,
DataSize));
Index = TempScale;
}
@@ -952,7 +951,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
if (const CompositeType *CT = dyn_cast<CompositeType>(LoadedTy)) {
std::vector<Value*> Indices;
- Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
+ Indices.push_back(ConstantSInt::get(Type::LongTy, 0));
unsigned Offset = 0; // No offset, get first leaf.
LoadedTy = getStructOffsetType(CT, Offset, Indices, false);
@@ -988,7 +987,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
const StructType *SElTy = cast<StructType>(ElTy);
std::vector<Value*> Indices;
- Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
+ Indices.push_back(Constant::getNullValue(Type::LongTy));
unsigned Offset = 0;
const Type *Ty = getStructOffsetType(ElTy, Offset, Indices, false);
@@ -1017,7 +1016,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
if (isa<StructType>(ValTy)) {
std::vector<Value*> Indices;
- Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
+ Indices.push_back(Constant::getNullValue(Type::LongTy));
unsigned Offset = 0;
ValTy = getStructOffsetType(ValTy, Offset, Indices, false);
@@ -1049,7 +1048,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
if (DataSize != 1) {
// Insert a multiply of the old element type is not a unit size...
Index = BinaryOperator::create(Instruction::Mul, Index,
- ConstantUInt::get(Type::UIntTy, DataSize),
+ ConstantSInt::get(Type::LongTy, DataSize),
"scale", It);
}
diff --git a/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp b/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp
index 2e5c0e7ffe..b8edb2260a 100644
--- a/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp
+++ b/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp
@@ -55,9 +55,9 @@ static void getTriggerCode(Module *M, BasicBlock *BB, int MethNo, Value *pathNo,
//M->getGlobalList().push_back(gbl);
- vector<Value *> elargs;
- elargs.push_back(ConstantUInt::get(Type::UIntTy, 0));
- elargs.push_back(ConstantUInt::get(Type::UIntTy, 0));
+ //vector<Value *> elargs;
+ //elargs.push_back(ConstantSInt::get(Type::LongTy, 0));
+ //elargs.push_back(ConstantSInt::get(Type::LongTy, 0));
// commented out bb name frm which its called
//Instruction *getElmntInst=new GetElementPtrInst(gbl,elargs,"elmntInst");
@@ -119,7 +119,7 @@ void getEdgeCode::getCode(Instruction *rInst,
assert(inc>=0 && inc<=numPaths && "inc out of bound!");
Instruction *Idx = new GetElementPtrInst(countInst,
- vector<Value*>(1,ConstantUInt::get(Type::UIntTy, inc)),
+ vector<Value*>(1,ConstantSInt::get(Type::LongTy, inc)),
"", InsertPos);
Instruction *ldInst=new LoadInst(Idx, "ti1", InsertPos);
@@ -154,7 +154,7 @@ void getEdgeCode::getCode(Instruction *rInst,
//now load count[addIndex]
Instruction *castInst=new CastInst(addIndex,
- Type::UIntTy,"ctin", InsertPos);
+ Type::LongTy,"ctin", InsertPos);
Instruction *Idx = new GetElementPtrInst(countInst,
vector<Value*>(1,castInst), "",
InsertPos);
@@ -184,7 +184,7 @@ void getEdgeCode::getCode(Instruction *rInst,
Instruction *ldIndex=new LoadInst(rInst, "ti1", InsertPos);
//now load count[addIndex]
- Instruction *castInst2=new CastInst(ldIndex, Type::UIntTy,"ctin",InsertPos);
+ Instruction *castInst2=new CastInst(ldIndex, Type::LongTy,"ctin",InsertPos);
Instruction *Idx = new GetElementPtrInst(countInst,
vector<Value*>(1,castInst2), "",
InsertPos);
@@ -236,10 +236,6 @@ void insertInTopBB(BasicBlock *front,
Value *Int0 = ConstantInt::get(Type::IntTy, 0);
- //store uint 0, uint *%R, uint 0
- vector<Value *> idx;
- idx.push_back(ConstantUInt::get(Type::UIntTy, 0));
-
//now push all instructions in front of the BB
BasicBlock::iterator here=front->begin();
front->getInstList().insert(here, rVar);
@@ -249,13 +245,13 @@ void insertInTopBB(BasicBlock *front,
for (int i=0;i<k; i++){
Value *GEP2 = new GetElementPtrInst(countVar,
- vector<Value *>(1,ConstantUInt::get(Type::UIntTy, i)),
+ vector<Value *>(1,ConstantSInt::get(Type::LongTy, i)),
"", here);
new StoreInst(Int0, GEP2, here);
}
- Instruction *GEP = new GetElementPtrInst(rVar, idx, "", here);
- new StoreInst(Int0, GEP, here);
+ //store uint 0, uint *%R
+ new StoreInst(Int0, rVar, here);
}
diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp
index f3fc7ba322..5abfe27238 100644
--- a/lib/Transforms/Instrumentation/TraceValues.cpp
+++ b/lib/Transforms/Instrumentation/TraceValues.cpp
@@ -226,7 +226,7 @@ static void InsertPrintInst(Value *V, BasicBlock *BB, Instruction *InsertBefore,
// Turn the format string into an sbyte *
Instruction *GEP =
new GetElementPtrInst(fmtVal,
- vector<Value*>(2,ConstantUInt::get(Type::UIntTy, 0)),
+ vector<Value*>(2,ConstantSInt::get(Type::LongTy, 0)),
"trstr", InsertBefore);
// Insert a call to the hash function if this is a pointer value
diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp
index 92f2f79381..fd32251bea 100644
--- a/lib/Transforms/LevelRaise.cpp
+++ b/lib/Transforms/LevelRaise.cpp
@@ -323,7 +323,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
// Build the index vector, full of all zeros
std::vector<Value*> Indices;
- Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
+ Indices.push_back(ConstantSInt::get(Type::LongTy, 0));
while (CurCTy && !isa<PointerType>(CurCTy)) {
if (const StructType *CurSTy = dyn_cast<StructType>(CurCTy)) {
// Check for a zero element struct type... if we have one, bail.
@@ -338,7 +338,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
}
// Insert a zero to index through this type...
- Indices.push_back(ConstantUInt::get(CurCTy->getIndexType(), 0));
+ Indices.push_back(Constant::getNullValue(CurCTy->getIndexType()));
// Did we find what we're looking for?
if (ElTy->isLosslesslyConvertableTo(DestPointedTy)) break;
diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp
index f9ee232b08..8586832076 100644
--- a/lib/Transforms/TransformInternals.cpp
+++ b/lib/Transforms/TransformInternals.cpp
@@ -66,7 +66,7 @@ const Type *getStructOffsetType(const Type *Ty, unsigned &Offset,
NextType = ATy->getElementType();
unsigned ChildSize = TD.getTypeSize(NextType);
- Indices.push_back(ConstantUInt::get(Type::UIntTy, Offset/ChildSize));
+ Indices.push_back(ConstantSInt::get(Type::LongTy, Offset/ChildSize));
ThisOffset = (Offset/ChildSize)*ChildSize;
} else {
Offset = 0; // Return the offset that we were able to acheive
@@ -141,13 +141,13 @@ const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal,
if (BI) { // Generate code?
BasicBlock *BB = (*BI)->getParent();
- if (Expr.Var->getType() != Type::UIntTy)
- Expr.Var = new CastInst(Expr.Var, Type::UIntTy,
+ if (Expr.Var->getType() != Type::LongTy)
+ Expr.Var = new CastInst(Expr.Var, Type::LongTy,
Expr.Var->getName()+"-idxcast", *BI);
if (ScaleAmt && ScaleAmt != 1) {
// If we have to scale up our index, do so now
- Value *ScaleAmtVal = ConstantUInt::get(Type::UIntTy,
+ Value *ScaleAmtVal = ConstantSInt::get(Type::LongTy,
(unsigned)ScaleAmt);
Expr.Var = BinaryOperator::create(Instruction::Mul, Expr.Var,
ScaleAmtVal,
@@ -155,7 +155,7 @@ const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal,
}
if (Index) { // Add an offset to the index
- Value *IndexAmt = ConstantUInt::get(Type::UIntTy, (unsigned)Index);
+ Value *IndexAmt = ConstantSInt::get(Type::LongTy, (unsigned)Index);
Expr.Var = BinaryOperator::create(Instruction::Add, Expr.Var,
IndexAmt,
Expr.Var->getName()+"-offset",
@@ -168,14 +168,14 @@ const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal,
} else if (Offset >= (int)ElSize || -Offset >= (int)ElSize) {
// Calculate the index that we are entering into the array cell with
unsigned Index = Offset/ElSize;
- Indices.push_back(ConstantUInt::get(Type::UIntTy, Index));
+ Indices.push_back(ConstantSInt::get(Type::LongTy, Index));
Offset -= (int)(Index*ElSize); // Consume part of the offset
} else if (isa<ArrayType>(CompTy) || Indices.empty()) {
// Must be indexing a small amount into the first cell of the array
// Just index into element zero of the array here.
//
- Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
+ Indices.push_back(ConstantSInt::get(Type::LongTy, 0));
} else {
return 0; // Hrm. wierd, can't handle this case. Bail
}