summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-12-31 05:48:39 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-12-31 05:48:39 +0000
commitc5b206b6be61d0d933b98b6af5e22f42edd48ad1 (patch)
tree9e6a1e6d3b90890de3d1464a44a7cef8d30fe1ae /lib
parent05e52a1b35e7feb359a176af462591697c4d9647 (diff)
downloadllvm-c5b206b6be61d0d933b98b6af5e22f42edd48ad1.tar.gz
llvm-c5b206b6be61d0d933b98b6af5e22f42edd48ad1.tar.bz2
llvm-c5b206b6be61d0d933b98b6af5e22f42edd48ad1.tar.xz
For PR950:
This patch replaces signed integer types with signless ones: 1. [US]Byte -> Int8 2. [U]Short -> Int16 3. [U]Int -> Int32 4. [U]Long -> Int64. 5. Removal of isSigned, isUnsigned, getSignedVersion, getUnsignedVersion and other methods related to signedness. In a few places this warranted identifying the signedness information from other sources. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32785 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp32
-rw-r--r--lib/Analysis/ConstantFolding.cpp1
-rw-r--r--lib/Analysis/ScalarEvolution.cpp56
-rw-r--r--lib/Transforms/ExprTypeConvert.cpp19
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp6
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp4
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp17
-rw-r--r--lib/Transforms/IPO/IndMemRemoval.cpp4
-rw-r--r--lib/Transforms/IPO/LowerSetJmp.cpp24
-rw-r--r--lib/Transforms/IPO/RaiseAllocations.cpp22
-rw-r--r--lib/Transforms/IPO/SimplifyLibCalls.cpp191
-rw-r--r--lib/Transforms/Instrumentation/BlockProfiling.cpp4
-rw-r--r--lib/Transforms/Instrumentation/EdgeProfiling.cpp2
-rw-r--r--lib/Transforms/Instrumentation/EmitFunctions.cpp8
-rw-r--r--lib/Transforms/Instrumentation/ProfilingUtils.cpp26
-rw-r--r--lib/Transforms/Instrumentation/RSProfiling.cpp16
-rw-r--r--lib/Transforms/Instrumentation/TraceBasicBlocks.cpp4
-rw-r--r--lib/Transforms/Instrumentation/TraceValues.cpp14
-rw-r--r--lib/Transforms/LevelRaise.cpp4
-rw-r--r--lib/Transforms/Scalar/CorrelatedExprs.cpp2
-rw-r--r--lib/Transforms/Scalar/IndVarSimplify.cpp5
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp291
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp12
-rw-r--r--lib/Transforms/Scalar/LowerGC.cpp18
-rw-r--r--lib/Transforms/Scalar/LowerPacked.cpp14
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp43
-rw-r--r--lib/Transforms/TransformInternals.cpp8
-rw-r--r--lib/Transforms/Utils/CodeExtractor.cpp24
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp2
-rw-r--r--lib/Transforms/Utils/LowerAllocations.cpp6
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp38
-rw-r--r--lib/Transforms/Utils/LowerSwitch.cpp4
32 files changed, 400 insertions, 521 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index d37a4b176f..caabc86f3f 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -269,7 +269,7 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size,
if (V1 == V2) return MustAlias;
if ((!isa<PointerType>(V1->getType()) || !isa<PointerType>(V2->getType())) &&
- V1->getType() != Type::LongTy && V2->getType() != Type::LongTy)
+ V1->getType() != Type::Int64Ty && V2->getType() != Type::Int64Ty)
return NoAlias; // Scalars cannot alias each other
// Strip off cast instructions...
@@ -458,14 +458,10 @@ static bool IndexOperandsEqual(Value *V1, Value *V2) {
if (Constant *C1 = dyn_cast<Constant>(V1))
if (Constant *C2 = dyn_cast<Constant>(V2)) {
// Sign extend the constants to long types, if necessary
- if (C1->getType()->getPrimitiveSizeInBits() < 64)
- C1 = ConstantExpr::getSExt(C1, Type::LongTy);
- else if (C1->getType() == Type::ULongTy)
- C1 = ConstantExpr::getBitCast(C1, Type::LongTy);
- if (C2->getType()->getPrimitiveSizeInBits() < 64)
- C2 = ConstantExpr::getSExt(C2, Type::LongTy);
- else if (C2->getType() == Type::ULongTy)
- C2 = ConstantExpr::getBitCast(C2, Type::LongTy);
+ if (C1->getType() != Type::Int64Ty)
+ C1 = ConstantExpr::getSExt(C1, Type::Int64Ty);
+ if (C2->getType() != Type::Int64Ty)
+ C2 = ConstantExpr::getSExt(C2, Type::Int64Ty);
return C1 == C2;
}
return false;
@@ -554,14 +550,10 @@ BasicAliasAnalysis::CheckGEPInstructions(
if (Constant *G2OC = dyn_cast<ConstantInt>(const_cast<Value*>(G2Oper))){
if (G1OC->getType() != G2OC->getType()) {
// Sign extend both operands to long.
- if (G1OC->getType()->getPrimitiveSizeInBits() < 64)
- G1OC = ConstantExpr::getSExt(G1OC, Type::LongTy);
- else if (G1OC->getType() == Type::ULongTy)
- G1OC = ConstantExpr::getBitCast(G1OC, Type::LongTy);
- if (G2OC->getType()->getPrimitiveSizeInBits() < 64)
- G2OC = ConstantExpr::getSExt(G2OC, Type::LongTy);
- else if (G2OC->getType() == Type::ULongTy)
- G2OC = ConstantExpr::getBitCast(G2OC, Type::LongTy);
+ if (G1OC->getType() != Type::Int64Ty)
+ G1OC = ConstantExpr::getSExt(G1OC, Type::Int64Ty);
+ if (G2OC->getType() != Type::Int64Ty)
+ G2OC = ConstantExpr::getSExt(G2OC, Type::Int64Ty);
GEP1Ops[FirstConstantOper] = G1OC;
GEP2Ops[FirstConstantOper] = G2OC;
}
@@ -661,7 +653,7 @@ BasicAliasAnalysis::CheckGEPInstructions(
const Type *ZeroIdxTy = GEPPointerTy;
for (unsigned i = 0; i != FirstConstantOper; ++i) {
if (!isa<StructType>(ZeroIdxTy))
- GEP1Ops[i] = GEP2Ops[i] = Constant::getNullValue(Type::UIntTy);
+ GEP1Ops[i] = GEP2Ops[i] = Constant::getNullValue(Type::Int32Ty);
if (const CompositeType *CT = dyn_cast<CompositeType>(ZeroIdxTy))
ZeroIdxTy = CT->getTypeAtIndex(GEP1Ops[i]);
@@ -702,9 +694,9 @@ BasicAliasAnalysis::CheckGEPInstructions(
// value possible.
//
if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty))
- GEP1Ops[i] = ConstantInt::get(Type::LongTy, AT->getNumElements()-1);
+ GEP1Ops[i] = ConstantInt::get(Type::Int64Ty, AT->getNumElements()-1);
else if (const PackedType *PT = dyn_cast<PackedType>(BasePtr1Ty))
- GEP1Ops[i] = ConstantInt::get(Type::LongTy, PT->getNumElements()-1);
+ GEP1Ops[i] = ConstantInt::get(Type::Int64Ty, PT->getNumElements()-1);
}
}
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index 359766d444..9f2be3e973 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -164,7 +164,6 @@ llvm::ConstantFoldCall(Function *F, const std::vector<Constant*> &Operands) {
break;
}
} else if (ConstantInt *Op = dyn_cast<ConstantInt>(Operands[0])) {
- assert(Op->getType()->isUnsigned() && "bswap args must be unsigned");
uint64_t V = Op->getZExtValue();
if (Name == "llvm.bswap.i16")
return ConstantInt::get(Ty, ByteSwap_16(V));
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index fcfab9e1c9..a43b585d9a 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -123,7 +123,6 @@ void SCEV::dump() const {
ConstantRange SCEV::getValueRange() const {
const Type *Ty = getType();
assert(Ty->isInteger() && "Can't get range for a non-integer SCEV!");
- Ty = Ty->getUnsignedVersion();
// Default to a full range if no better information is available.
return ConstantRange(getType());
}
@@ -172,14 +171,6 @@ SCEVConstant::~SCEVConstant() {
}
SCEVHandle SCEVConstant::get(ConstantInt *V) {
- // Make sure that SCEVConstant instances are all unsigned.
- // FIXME:Signless. This entire if statement can be removed when integer types
- // are signless. There won't be a need to bitcast then.
- if (V->getType()->isSigned()) {
- const Type *NewTy = V->getType()->getUnsignedVersion();
- V = cast<ConstantInt>(ConstantExpr::getBitCast(V, NewTy));
- }
-
SCEVConstant *&R = (*SCEVConstants)[V];
if (R == 0) R = new SCEVConstant(V);
return R;
@@ -310,9 +301,7 @@ void SCEVSDivExpr::print(std::ostream &OS) const {
}
const Type *SCEVSDivExpr::getType() const {
- const Type *Ty = LHS->getType();
- if (Ty->isUnsigned()) Ty = Ty->getSignedVersion();
- return Ty;
+ return LHS->getType();
}
// SCEVAddRecExprs - Only allow the creation of one SCEVAddRecExpr for any
@@ -505,7 +494,7 @@ static SCEVHandle PartialFact(SCEVHandle V, unsigned NumSteps) {
uint64_t Result = 1;
for (; NumSteps; --NumSteps)
Result *= Val-(NumSteps-1);
- Constant *Res = ConstantInt::get(Type::ULongTy, Result);
+ Constant *Res = ConstantInt::get(Type::Int64Ty, Result);
return SCEVUnknown::get(ConstantExpr::getTruncOrBitCast(Res, V->getType()));
}
@@ -1427,15 +1416,13 @@ SCEVHandle ScalarEvolutionsImpl::createSCEV(Value *V) {
case Instruction::Trunc:
// We don't handle trunc to bool yet.
if (I->getType()->isInteger())
- return SCEVTruncateExpr::get(getSCEV(I->getOperand(0)),
- I->getType()->getUnsignedVersion());
+ return SCEVTruncateExpr::get(getSCEV(I->getOperand(0)), I->getType());
break;
case Instruction::ZExt:
// We don't handle zext from bool yet.
if (I->getOperand(0)->getType()->isInteger())
- return SCEVZeroExtendExpr::get(getSCEV(I->getOperand(0)),
- I->getType()->getUnsignedVersion());
+ return SCEVZeroExtendExpr::get(getSCEV(I->getOperand(0)), I->getType());
break;
case Instruction::BitCast:
@@ -1572,21 +1559,8 @@ SCEVHandle ScalarEvolutionsImpl::ComputeIterationCount(const Loop *L) {
// Form the constant range.
ConstantRange CompRange(Cond, CompVal);
- // Now that we have it, if it's signed, convert it to an unsigned
- // range.
- // FIXME:Signless. This entire if statement can go away when
- // integers are signless. ConstantRange is already signless.
- if (CompRange.getLower()->getType()->isSigned()) {
- const Type *NewTy = RHSC->getValue()->getType();
- Constant *NewL = ConstantExpr::getBitCast(CompRange.getLower(),
- NewTy);
- Constant *NewU = ConstantExpr::getBitCast(CompRange.getUpper(),
- NewTy);
- CompRange = ConstantRange(NewL, NewU);
- }
-
SCEVHandle Ret = AddRec->getNumIterationsInRange(CompRange,
- ICmpInst::isSignedPredicate(Cond));
+ false /*Always treat as unsigned range*/);
if (!isa<SCEVCouldNotCompute>(Ret)) return Ret;
}
}
@@ -1723,7 +1697,7 @@ ComputeLoadConstantCompareIterationCount(LoadInst *LI, Constant *RHS,
unsigned MaxSteps = MaxBruteForceIterations;
for (unsigned IterationNum = 0; IterationNum != MaxSteps; ++IterationNum) {
ConstantInt *ItCst =
- ConstantInt::get(IdxExpr->getType()->getUnsignedVersion(), IterationNum);
+ ConstantInt::get(IdxExpr->getType(), IterationNum);
ConstantInt *Val = EvaluateConstantChrecAtConstant(IdxExpr, ItCst);
// Form the GEP offset.
@@ -1946,7 +1920,7 @@ ComputeIterationCountExhaustively(const Loop *L, Value *Cond, bool ExitWhen) {
if (CondVal->getValue() == ExitWhen) {
ConstantEvolutionLoopExitValue[PN] = PHIVal;
++NumBruteForceTripCountsComputed;
- return SCEVConstant::get(ConstantInt::get(Type::UIntTy, IterationNum));
+ return SCEVConstant::get(ConstantInt::get(Type::Int32Ty, IterationNum));
}
// Compute the value of the PHI node for the next iteration.
@@ -2129,10 +2103,7 @@ SolveQuadraticEquation(const SCEVAddRecExpr *AddRec) {
SqrtTerm = ConstantExpr::getSub(ConstantExpr::getMul(B, B), SqrtTerm);
// Compute floor(sqrt(B^2-4ac))
- ConstantInt *SqrtVal =
- cast<ConstantInt>(ConstantExpr::getBitCast(SqrtTerm,
- SqrtTerm->getType()->getUnsignedVersion()));
- uint64_t SqrtValV = SqrtVal->getZExtValue();
+ uint64_t SqrtValV = cast<ConstantInt>(SqrtTerm)->getZExtValue();
uint64_t SqrtValV2 = (uint64_t)sqrt((double)SqrtValV);
// The square root might not be precise for arbitrary 64-bit integer
// values. Do some sanity checks to ensure it's correct.
@@ -2142,20 +2113,13 @@ SolveQuadraticEquation(const SCEVAddRecExpr *AddRec) {
return std::make_pair(CNC, CNC);
}
- SqrtVal = ConstantInt::get(Type::ULongTy, SqrtValV2);
+ ConstantInt *SqrtVal = ConstantInt::get(Type::Int64Ty, SqrtValV2);
SqrtTerm = ConstantExpr::getTruncOrBitCast(SqrtVal, SqrtTerm->getType());
Constant *NegB = ConstantExpr::getNeg(B);
Constant *TwoA = ConstantExpr::getMul(A, Two);
// The divisions must be performed as signed divisions.
- // FIXME:Signedness. These casts can all go away once integer types are
- // signless.
- const Type *SignedTy = NegB->getType()->getSignedVersion();
- NegB = ConstantExpr::getBitCast(NegB, SignedTy);
- TwoA = ConstantExpr::getBitCast(TwoA, SignedTy);
- SqrtTerm = ConstantExpr::getBitCast(SqrtTerm, SignedTy);
-
Constant *Solution1 =
ConstantExpr::getSDiv(ConstantExpr::getAdd(NegB, SqrtTerm), TwoA);
Constant *Solution2 =
@@ -2222,7 +2186,6 @@ SCEVHandle ScalarEvolutionsImpl::HowFarToZero(SCEV *V, const Loop *L) {
<< " sol#2: " << *R2 << "\n";
#endif
// Pick the smallest positive root value.
- assert(R1->getType()->isUnsigned()&&"Didn't canonicalize to unsigned?");
if (ConstantBool *CB =
dyn_cast<ConstantBool>(ConstantExpr::getICmp(ICmpInst::ICMP_ULT,
R1->getValue(), R2->getValue()))) {
@@ -2448,7 +2411,6 @@ SCEVHandle SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range,
SCEVConstant *R2 = dyn_cast<SCEVConstant>(Roots.second);
if (R1) {
// Pick the smallest positive root value.
- assert(R1->getType()->isUnsigned() && "Didn't canonicalize to unsigned?");
if (ConstantBool *CB =
dyn_cast<ConstantBool>(ConstantExpr::getICmp(ICmpInst::ICMP_ULT,
R1->getValue(), R2->getValue()))) {
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index 5f6b6aebf9..9f99f95642 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -210,8 +210,9 @@ Value *llvm::ConvertExpressionToType(Value *V, const Type *Ty,
Constant *CPV = cast<Constant>(V);
// Constants are converted by constant folding the cast that is required.
// We assume here that all casts are implemented for constant prop.
- Instruction::CastOps opcode = CastInst::getCastOpcode(CPV,
- CPV->getType()->isSigned(), Ty, Ty->isSigned());
+ // FIXME: This seems to work, but it is unclear why ZEXT is always the
+ // right choice here.
+ Instruction::CastOps opcode = CastInst::getCastOpcode(CPV, false, Ty,false);
Value *Result = ConstantExpr::getCast(opcode, CPV, Ty);
// Add the instruction to the expression map
//VMC.ExprMap[V] = Result;
@@ -231,7 +232,7 @@ Value *llvm::ConvertExpressionToType(Value *V, const Type *Ty,
case Instruction::BitCast: {
assert(VMC.NewCasts.count(ValueHandle(VMC, I)) == 0);
Instruction::CastOps opcode = CastInst::getCastOpcode(I->getOperand(0),
- I->getOperand(0)->getType()->isSigned(), Ty, Ty->isSigned());
+ false, Ty, false);
Res = CastInst::create(opcode, I->getOperand(0), Ty, Name);
VMC.NewCasts.insert(ValueHandle(VMC, Res));
break;
@@ -473,8 +474,6 @@ static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty,
}
case Instruction::LShr:
case Instruction::AShr:
- if (Ty->isSigned() != V->getType()->isSigned()) return false;
- // FALL THROUGH
case Instruction::Shl:
if (I->getOperand(1) == V) return false; // Cannot change shift amount type
if (!Ty->isInteger()) return false;
@@ -713,8 +712,8 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
switch (I->getOpcode()) {
case Instruction::BitCast: {
- Instruction::CastOps opcode = CastInst::getCastOpcode(NewVal,
- NewVal->getType()->isSigned(), I->getType(), I->getType()->isSigned());
+ Instruction::CastOps opcode = CastInst::getCastOpcode(NewVal, false,
+ I->getType(), false);
Res = CastInst::create(opcode, NewVal, I->getType(), Name);
break;
}
@@ -768,7 +767,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(Constant::getNullValue(Type::UIntTy));
+ Indices.push_back(Constant::getNullValue(Type::Int32Ty));
unsigned Offset = 0; // No offset, get first leaf.
LoadedTy = getStructOffsetType(CT, Offset, Indices, TD, false);
@@ -801,7 +800,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
if (ElTy != NewTy) {
std::vector<Value*> Indices;
- Indices.push_back(Constant::getNullValue(Type::UIntTy));
+ Indices.push_back(Constant::getNullValue(Type::Int32Ty));
unsigned Offset = 0;
const Type *Ty = getStructOffsetType(ElTy, Offset, Indices, TD,false);
@@ -830,7 +829,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
if (isa<StructType>(ValTy)) {
std::vector<Value*> Indices;
- Indices.push_back(Constant::getNullValue(Type::UIntTy));
+ Indices.push_back(Constant::getNullValue(Type::Int32Ty));
unsigned Offset = 0;
ValTy = getStructOffsetType(ValTy, Offset, Indices, TD, false);
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp
index ab52baf850..467214dce6 100644
--- a/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -384,7 +384,7 @@ Function *ArgPromotion::DoPromotion(Function *F,
bool ExtraArgHack = false;
if (Params.empty() && FTy->isVarArg()) {
ExtraArgHack = true;
- Params.push_back(Type::IntTy);
+ Params.push_back(Type::Int32Ty);
}
FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
@@ -429,7 +429,7 @@ Function *ArgPromotion::DoPromotion(Function *F,
}
if (ExtraArgHack)
- Args.push_back(Constant::getNullValue(Type::IntTy));
+ Args.push_back(Constant::getNullValue(Type::Int32Ty));
// Push any varargs arguments on the list
for (; AI != CS.arg_end(); ++AI)
@@ -540,7 +540,7 @@ Function *ArgPromotion::DoPromotion(Function *F,
// Notify the alias analysis implementation that we inserted a new argument.
if (ExtraArgHack)
- AA.copyValue(Constant::getNullValue(Type::IntTy), NF->arg_begin());
+ AA.copyValue(Constant::getNullValue(Type::Int32Ty), NF->arg_begin());
// Tell the alias analysis that the old function is about to disappear.
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 9d88a8879f..840533f968 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -500,7 +500,7 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
bool ExtraArgHack = false;
if (Params.empty() && FTy->isVarArg()) {
ExtraArgHack = true;
- Params.push_back(Type::IntTy);
+ Params.push_back(Type::Int32Ty);
}
FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
@@ -526,7 +526,7 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
Args.push_back(*AI);
if (ExtraArgHack)
- Args.push_back(UndefValue::get(Type::IntTy));
+ Args.push_back(UndefValue::get(Type::Int32Ty));
// Push any varargs arguments on the list
for (; AI != CS.arg_end(); ++AI)
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 808a7f805d..e17ded82d9 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -384,7 +384,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV) {
NewGlobals.reserve(STy->getNumElements());
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
Constant *In = getAggregateConstantElement(Init,
- ConstantInt::get(Type::UIntTy, i));
+ ConstantInt::get(Type::Int32Ty, i));
assert(In && "Couldn't get element of initializer?");
GlobalVariable *NGV = new GlobalVariable(STy->getElementType(i), false,
GlobalVariable::InternalLinkage,
@@ -406,7 +406,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV) {
NewGlobals.reserve(NumElements);
for (unsigned i = 0, e = NumElements; i != e; ++i) {
Constant *In = getAggregateConstantElement(Init,
- ConstantInt::get(Type::UIntTy, i));
+ ConstantInt::get(Type::Int32Ty, i));
assert(In && "Couldn't get element of initializer?");
GlobalVariable *NGV = new GlobalVariable(STy->getElementType(), false,
@@ -422,7 +422,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV) {
DOUT << "PERFORMING GLOBAL SRA ON: " << *GV;
- Constant *NullInt = Constant::getNullValue(Type::IntTy);
+ Constant *NullInt = Constant::getNullValue(Type::Int32Ty);
// Loop over all of the uses of the global, replacing the constantexpr geps,
// with smaller constantexpr geps or direct references.
@@ -679,10 +679,10 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
Type *NewTy = ArrayType::get(MI->getAllocatedType(),
NElements->getZExtValue());
MallocInst *NewMI =
- new MallocInst(NewTy, Constant::getNullValue(Type::UIntTy),
+ new MallocInst(NewTy, Constant::getNullValue(Type::Int32Ty),
MI->getAlignment(), MI->getName(), MI);
std::vector<Value*> Indices;
- Indices.push_back(Constant::getNullValue(Type::IntTy));
+ Indices.push_back(Constant::getNullValue(Type::Int32Ty));
Indices.push_back(Indices[0]);
Value *NewGEP = new GetElementPtrInst(NewMI, Indices,
NewMI->getName()+".el0", MI);
@@ -892,7 +892,6 @@ static void RewriteUsesOfLoadForHeapSRoA(LoadInst *Ptr,
// Otherwise, this should be: 'getelementptr Ptr, Idx, uint FieldNo ...'
GetElementPtrInst *GEPI = cast<GetElementPtrInst>(User);
assert(GEPI->getNumOperands() >= 3 && isa<ConstantInt>(GEPI->getOperand(2))
- && GEPI->getOperand(2)->getType()->isUnsigned()
&& "Unexpected GEPI!");
// Load the pointer for this field.
@@ -1415,7 +1414,7 @@ GlobalVariable *GlobalOpt::FindGlobalCtors(Module &M) {
if (!ATy) return 0;
const StructType *STy = dyn_cast<StructType>(ATy->getElementType());
if (!STy || STy->getNumElements() != 2 ||
- STy->getElementType(0) != Type::IntTy) return 0;
+ STy->getElementType(0) != Type::Int32Ty) return 0;
const PointerType *PFTy = dyn_cast<PointerType>(STy->getElementType(1));
if (!PFTy) return 0;
const FunctionType *FTy = dyn_cast<FunctionType>(PFTy->getElementType());
@@ -1468,7 +1467,7 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL,
const std::vector<Function*> &Ctors) {
// If we made a change, reassemble the initializer list.
std::vector<Constant*> CSVals;
- CSVals.push_back(ConstantInt::get(Type::IntTy, 65535));
+ CSVals.push_back(ConstantInt::get(Type::Int32Ty, 65535));
CSVals.push_back(0);
// Create the new init list.
@@ -1481,7 +1480,7 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL,
std::vector<const Type*>(), false);
const PointerType *PFTy = PointerType::get(FTy);
CSVals[1] = Constant::getNullValue(PFTy);
- CSVals[0] = ConstantInt::get(Type::IntTy, 2147483647);
+ CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647);
}
CAList.push_back(ConstantStruct::get(CSVals));
}
diff --git a/lib/Transforms/IPO/IndMemRemoval.cpp b/lib/Transforms/IPO/IndMemRemoval.cpp
index 82aa992a09..c68a4d3b24 100644
--- a/lib/Transforms/IPO/IndMemRemoval.cpp
+++ b/lib/Transforms/IPO/IndMemRemoval.cpp
@@ -66,8 +66,8 @@ bool IndMemRemPass::runOnModule(Module &M) {
"malloc_llvm_bounce", &M);
BasicBlock* bb = new BasicBlock("entry",FN);
Instruction* c = CastInst::createIntegerCast(
- FN->arg_begin(), Type::UIntTy, false, "c", bb);
- Instruction* a = new MallocInst(Type::SByteTy, c, "m", bb);
+ FN->arg_begin(), Type::Int32Ty, false, "c", bb);
+ Instruction* a = new MallocInst(Type::Int8Ty, c, "m", bb);
new ReturnInst(a, bb);
++NumBounce;
NumBounceSites += F->getNumUses();
diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp
index d7f22fb9cb..44b0ab5d5c 100644
--- a/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/lib/Transforms/IPO/LowerSetJmp.cpp
@@ -193,7 +193,7 @@ bool LowerSetJmp::runOnModule(Module& M) {
// This function is always successful, unless it isn't.
bool LowerSetJmp::doInitialization(Module& M)
{
- const Type *SBPTy = PointerType::get(Type::SByteTy);
+ const Type *SBPTy = PointerType::get(Type::Int8Ty);
const Type *SBPPTy = PointerType::get(SBPTy);
// N.B. See llvm/runtime/GCCLibraries/libexception/SJLJ-Exception.h for
@@ -209,17 +209,17 @@ bool LowerSetJmp::doInitialization(Module& M)
// void __llvm_sjljeh_add_setjmp_to_map(void**, void*, unsigned)
AddSJToMap = M.getOrInsertFunction("__llvm_sjljeh_add_setjmp_to_map",
Type::VoidTy, SBPPTy, SBPTy,
- Type::UIntTy, (Type *)0);
+ Type::Int32Ty, (Type *)0);
// void __llvm_sjljeh_throw_longjmp(int*, int)
ThrowLongJmp = M.getOrInsertFunction("__llvm_sjljeh_throw_longjmp",
- Type::VoidTy, SBPTy, Type::IntTy,
+ Type::VoidTy, SBPTy, Type::Int32Ty,
(Type *)0);
// unsigned __llvm_sjljeh_try_catching_longjmp_exception(void **)
TryCatchLJ =
M.getOrInsertFunction("__llvm_sjljeh_try_catching_longjmp_exception",
- Type::UIntTy, SBPPTy, (Type *)0);
+ Type::Int32Ty, SBPPTy, (Type *)0);
// bool __llvm_sjljeh_is_longjmp_exception()
IsLJException = M.getOrInsertFunction("__llvm_sjljeh_is_longjmp_exception",
@@ -227,7 +227,7 @@ bool LowerSetJmp::doInitialization(Module& M)
// int __llvm_sjljeh_get_longjmp_value()
GetLJValue = M.getOrInsertFunction("__llvm_sjljeh_get_longjmp_value",
- Type::IntTy, (Type *)0);
+ Type::Int32Ty, (Type *)0);
return true;
}
@@ -250,7 +250,7 @@ bool LowerSetJmp::IsTransformableFunction(const std::string& Name) {
// throwing the exception for us.
void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
{
- const Type* SBPTy = PointerType::get(Type::SByteTy);
+ const Type* SBPTy = PointerType::get(Type::Int8Ty);
// Create the call to "__llvm_sjljeh_throw_longjmp". This takes the
// same parameters as "longjmp", except that the buffer is cast to a
@@ -300,7 +300,7 @@ AllocaInst* LowerSetJmp::GetSetJmpMap(Function* Func)
assert(Inst && "Couldn't find even ONE instruction in entry block!");
// Fill in the alloca and call to initialize the SJ map.
- const Type *SBPTy = PointerType::get(Type::SByteTy);
+ const Type *SBPTy = PointerType::get(Type::Int8Ty);
AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst);
new CallInst(InitSJMap, make_vector<Value*>(Map, 0), "", Inst);
return SJMap[Func] = Map;
@@ -372,12 +372,12 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst)
Function* Func = ABlock->getParent();
// Add this setjmp to the setjmp map.
- const Type* SBPTy = PointerType::get(Type::SByteTy);
+ const Type* SBPTy = PointerType::get(Type::Int8Ty);
CastInst* BufPtr =
new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst);
new CallInst(AddSJToMap,
make_vector<Value*>(GetSetJmpMap(Func), BufPtr,
- ConstantInt::get(Type::UIntTy,
+ ConstantInt::get(Type::Int32Ty,
SetJmpIDMap[Func]++), 0),
"", Inst);
@@ -421,14 +421,14 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst)
// This PHI node will be in the new block created from the
// splitBasicBlock call.
- PHINode* PHI = new PHINode(Type::IntTy, "SetJmpReturn", Inst);
+ PHINode* PHI = new PHINode(Type::Int32Ty, "SetJmpReturn", Inst);
// Coming from a call to setjmp, the return is 0.
- PHI->addIncoming(ConstantInt::getNullValue(Type::IntTy), ABlock);
+ PHI->addIncoming(ConstantInt::getNullValue(Type::Int32Ty), ABlock);
// Add the case for this setjmp's number...
SwitchValuePair SVP = GetSJSwitch(Func, GetRethrowBB(Func));
- SVP.first->addCase(ConstantInt::get(Type::UIntTy, SetJmpIDMap[Func] - 1),
+ SVP.first->addCase(ConstantInt::get(Type::Int32Ty, SetJmpIDMap[Func] - 1),
SetJmpContBlock);
// Value coming from the handling of the exception.
diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp
index 58f0d1b0a3..e7e57aa952 100644
--- a/lib/Transforms/IPO/RaiseAllocations.cpp
+++ b/lib/Transforms/IPO/RaiseAllocations.cpp
@@ -66,12 +66,12 @@ ModulePass *llvm::createRaiseAllocationsPass() {
//
void RaiseAllocations::doInitialization(Module &M) {
const FunctionType *MallocType = // Get the type for malloc
- FunctionType::get(PointerType::get(Type::SByteTy),
- std::vector<const Type*>(1, Type::ULongTy), false);
+ FunctionType::get(PointerType::get(Type::Int8Ty),
+ std::vector<const Type*>(1, Type::Int64Ty), false);
const FunctionType *FreeType = // Get the type for free
FunctionType::get(Type::VoidTy,
- std::vector<const Type*>(1, PointerType::get(Type::SByteTy)),
+ std::vector<const Type*>(1, PointerType::get(Type::Int8Ty)),
false);
// Get Malloc and free prototypes if they exist!
@@ -81,15 +81,15 @@ void RaiseAllocations::doInitialization(Module &M) {
// Check to see if the prototype is wrong, giving us sbyte*(uint) * malloc
// This handles the common declaration of: 'void *malloc(unsigned);'
if (MallocFunc == 0) {
- MallocType = FunctionType::get(PointerType::get(Type::SByteTy),
- std::vector<const Type*>(1, Type::UIntTy), false);
+ MallocType = FunctionType::get(PointerType::get(Type::Int8Ty),
+ std::vector<const Type*>(1, Type::Int32Ty), false);
MallocFunc = M.getFunction("malloc", MallocType);
}
// Check to see if the prototype is missing, giving us sbyte*(...) * malloc
// This handles the common declaration of: 'void *malloc();'
if (MallocFunc == 0) {
- MallocType = FunctionType::get(PointerType::get(Type::SByteTy),
+ MallocType = FunctionType::get(PointerType::get(Type::Int8Ty),
std::vector<const Type*>(), true);
MallocFunc = M.getFunction("malloc", MallocType);
}
@@ -104,7 +104,7 @@ void RaiseAllocations::doInitialization(Module &M) {
// One last try, check to see if we can find free as 'int (...)* free'. This
// handles the case where NOTHING was declared.
if (FreeFunc == 0) {
- FreeType = FunctionType::get(Type::IntTy, std::vector<const Type*>(),true);
+ FreeType = FunctionType::get(Type::Int32Ty, std::vector<const Type*>(),true);
FreeFunc = M.getFunction("free", FreeType);
}
@@ -140,13 +140,13 @@ bool RaiseAllocations::runOnModule(Module &M) {
// If no prototype was provided for malloc, we may need to cast the
// source size.
- if (Source->getType() != Type::UIntTy)
+ if (Source->getType() != Type::Int32Ty)
Source =
- CastInst::createIntegerCast(Source, Type::UIntTy, false/*ZExt*/,
+ CastInst::createIntegerCast(Source, Type::Int32Ty, false/*ZExt*/,
"MallocAmtCast", I);
std::string Name(I->getName()); I->setName("");
- MallocInst *MI = new MallocInst(Type::SByteTy, Source, Name, I);
+ MallocInst *MI = new MallocInst(Type::Int8Ty, Source, Name, I);
I->replaceAllUsesWith(MI);
// If the old instruction was an invoke, add an unconditional branch
@@ -194,7 +194,7 @@ bool RaiseAllocations::runOnModule(Module &M) {
//
Value *Source = *CS.arg_begin();
if (!isa<PointerType>(Source->getType()))
- Source = new IntToPtrInst(Source, PointerType::get(Type::SByteTy),
+ Source = new IntToPtrInst(Source, PointerType::get(Type::Int8Ty),
"FreePtrCast", I);
new FreeInst(Source, I);
diff --git a/lib/Transforms/IPO/SimplifyLibCalls.cpp b/lib/Transforms/IPO/SimplifyLibCalls.cpp
index b4e840641b..4d37fbf79a 100644
--- a/lib/Transforms/IPO/SimplifyLibCalls.cpp
+++ b/lib/Transforms/IPO/SimplifyLibCalls.cpp
@@ -224,16 +224,16 @@ public:
/// @brief Return a Function* for the putchar libcall
Function* get_putchar() {
if (!putchar_func)
- putchar_func = M->getOrInsertFunction("putchar", Type::IntTy, Type::IntTy,
- NULL);
+ putchar_func =
+ M->getOrInsertFunction("putchar", Type::Int32Ty, Type::Int32Ty, NULL);
return putchar_func;
}
/// @brief Return a Function* for the puts libcall
Function* get_puts() {
if (!puts_func)
- puts_func = M->getOrInsertFunction("puts", Type::IntTy,
- PointerType::get(Type::SByteTy),
+ puts_func = M->getOrInsertFunction("puts", Type::Int32Ty,
+ PointerType::get(Type::Int8Ty),
NULL);
return puts_func;
}
@@ -241,7 +241,7 @@ public:
/// @brief Return a Function* for the fputc libcall
Function* get_fputc(const Type* FILEptr_type) {
if (!fputc_func)
- fputc_func = M->getOrInsertFunction("fputc", Type::IntTy, Type::IntTy,
+ fputc_func = M->getOrInsertFunction("fputc", Type::Int32Ty, Type::Int32Ty,
FILEptr_type, NULL);
return fputc_func;
}
@@ -249,8 +249,8 @@ public:
/// @brief Return a Function* for the fputs libcall
Function* get_fputs(const Type* FILEptr_type) {
if (!fputs_func)
- fputs_func = M->getOrInsertFunction("fputs", Type::IntTy,
- PointerType::get(Type::SByteTy),
+ fputs_func = M->getOrInsertFunction("fputs", Type::Int32Ty,
+ PointerType::get(Type::Int8Ty),
FILEptr_type, NULL);
return fputs_func;
}
@@ -259,7 +259,7 @@ public:
Function* get_fwrite(const Type* FILEptr_type) {
if (!fwrite_func)
fwrite_func = M->getOrInsertFunction("fwrite", TD->getIntPtrType(),
- PointerType::get(Type::SByteTy),
+ PointerType::get(Type::Int8Ty),
TD->getIntPtrType(),
TD->getIntPtrType(),
FILEptr_type, NULL);
@@ -278,9 +278,9 @@ public:
Function* get_strcpy() {
if (!strcpy_func)
strcpy_func = M->getOrInsertFunction("strcpy",
- PointerType::get(Type::SByteTy),
- PointerType::get(Type::SByteTy),
- PointerType::get(Type::SByteTy),
+ PointerType::get(Type::Int8Ty),
+ PointerType::get(Type::Int8Ty),
+ PointerType::get(Type::Int8Ty),
NULL);
return strcpy_func;
}
@@ -289,7 +289,7 @@ public:
Function* get_strlen() {
if (!strlen_func)
strlen_func = M->getOrInsertFunction("strlen", TD->getIntPtrType(),
- PointerType::get(Type::SByteTy),
+ PointerType::get(Type::Int8Ty),
NULL);
return strlen_func;
}
@@ -298,9 +298,9 @@ public:
Function* get_memchr() {
if (!memchr_func)
memchr_func = M->getOrInsertFunction("memchr",
- PointerType::get(Type::SByteTy),
- PointerType::get(Type::SByteTy),
- Type::IntTy, TD->getIntPtrType(),
+ PointerType::get(Type::Int8Ty),
+ PointerType::get(Type::Int8Ty),
+ Type::Int32Ty, TD->getIntPtrType(),
NULL);
return memchr_func;
}
@@ -308,11 +308,11 @@ public:
/// @brief Return a Function* for the memcpy libcall
Function* get_memcpy() {
if (!memcpy_func) {
- const Type *SBP = PointerType::get(Type::SByteTy);
- const char *N = TD->getIntPtrType() == Type::UIntTy ?
+ const Type *SBP = PointerType::get(Type::Int8Ty);
+ const char *N = TD->getIntPtrType() == Type::Int32Ty ?
"llvm.memcpy.i32" : "llvm.memcpy.i64";
memcpy_func = M->getOrInsertFunction(N, Type::VoidTy, SBP, SBP,
- TD->getIntPtrType(), Type::UIntTy,
+ TD->getIntPtrType(), Type::Int32Ty,
NULL);
}
return memcpy_func;
@@ -457,12 +457,12 @@ public:
/// @brief Make sure that the "strcat" function has the right prototype
virtual bool ValidateCalledFunction(const Function* f, SimplifyLibCalls& SLC){
- if (f->getReturnType() == PointerType::get(Type::SByteTy))
+ if (f->getReturnType() == PointerType::get(Type::Int8Ty))
if (f->arg_size() == 2)
{
Function::const_arg_iterator AI = f->arg_begin();
- if (AI++->getType() == PointerType::get(Type::SByteTy))
- if (AI->getType() == PointerType::get(Type::SByteTy))
+ if (AI++->getType() == PointerType::get(Type::Int8Ty))
+ if (AI->getType() == PointerType::get(Type::Int8Ty))
{
// Indicate this is a suitable call type.
return true;
@@ -516,7 +516,7 @@ public:
vals.push_back(gep); // destination
vals.push_back(ci->getOperand(2)); // source
vals.push_back(ConstantInt::get(SLC.getIntPtrType(),len)); // length
- vals.push_back(ConstantInt::get(Type::UIntTy,1)); // alignment
+ vals.push_back(ConstantInt::get(Type::Int32Ty,1)); // alignment
new CallInst(SLC.get_memcpy(), vals, "", ci);
// Finally, substitute the first operand of the strcat call for the
@@ -539,7 +539,7 @@ public:
/// @brief Make sure that the "strchr" function has the right prototype
virtual bool ValidateCalledFunction(const Function* f, SimplifyLibCalls& SLC){
- if (f->getReturnType() == PointerType::get(Type::SByteTy) &&
+ if (f->getReturnType() == PointerType::get(Type::Int8Ty) &&
f->arg_size() == 2)
return true;
return false;
@@ -555,21 +555,21 @@ public:
// If it is, get the length and data, otherwise return false.
uint64_t len = 0;
ConstantArray* CA = 0;
- if (!getConstantStringLength(ci->getOperand(1),len,&CA))
+ if (!getConstantStringLength(ci->getOperand(1), len, &CA))
return false;
// Check that the second argument to strchr is a constant int. If it isn't
// a constant signed integer, we can try an alternate optimization
ConstantInt* CSI = dyn_cast<ConstantInt>(ci->getOperand(2));
- if (!CSI || CSI->getType()->isUnsigned() ) {
+ if (!CSI) {
// The second operand is not constant, or not signed. Just lower this to
// memchr since we know the length of the string since it is constant.
Function* f = SLC.get_memchr();
std::vector<Value*> args;
args.push_back(ci->getOperand(1));
args.push_back(ci->getOperand(2));
- args.push_back(ConstantInt::get(SLC.getIntPtrType(),len));
- ci->replaceAllUsesWith( new CallInst(f,args,ci->getName(),ci));
+ args.push_back(ConstantInt::get(SLC.getIntPtrType(), len));
+ ci->replaceAllUsesWith( new CallInst(f, args, ci->getName(), ci));
ci->eraseFromParent();
return true;
}
@@ -597,13 +597,13 @@ public:
// (if c is a constant integer and s is a constant string)
if (char_found) {
std::vector<Value*> indices;
- indices.push_back(ConstantInt::get(Type::ULongTy,offset));
+ indices.push_back(ConstantInt::get(Type::Int64Ty,offset));
GetElementPtrInst* GEP = new GetElementPtrInst(ci->getOperand(1),indices,
ci->getOperand(1)->getName()+".strchr",ci);
ci->replaceAllUsesWith(GEP);
} else {
ci->replaceAllUsesWith(
- ConstantPointerNull::get(PointerType::get(Type::SByteTy)));
+ ConstantPointerNull::get(PointerType::get(Type::Int8Ty)));
}
ci->eraseFromParent();
return true;
@@ -621,7 +621,7 @@ public:
/// @brief Make sure that the "strcmp" function has the right prototype
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
- return F->getReturnType() == Type::IntTy && F->arg_size() == 2;
+ return F->getReturnType() == Type::Int32Ty && F->arg_size() == 2;
}
/// @brief Perform the strcmp optimization
@@ -633,7 +633,7 @@ public:
Value* s2 = ci->getOperand(2);
if (s1 == s2) {
// strcmp(x,x) -> 0
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,0));
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,0));
ci->eraseFromParent();
return true;
}
@@ -648,7 +648,7 @@ public:
LoadInst* load =
new LoadInst(CastToCStr(s2,*ci), ci->getName()+".load",ci);
CastInst* cast =
- CastInst::create(Instruction::SExt, load, Type::IntTy,
+ CastInst::create(Instruction::SExt, load, Type::Int32Ty,
ci->getName()+".int", ci);
ci->replaceAllUsesWith(cast);
ci->eraseFromParent();
@@ -666,7 +666,7 @@ public:
LoadInst* load =
new LoadInst(CastToCStr(s1,*ci),ci->getName()+".val",ci);
CastInst* cast =
- CastInst::create(Instruction::SExt, load, Type::IntTy,
+ CastInst::create(Instruction::SExt, load, Type::Int32Ty,
ci->getName()+".int", ci);
ci->replaceAllUsesWith(cast);
ci->eraseFromParent();
@@ -679,7 +679,7 @@ public:
std::string str1 = A1->getAsString();
std::string str2 = A2->getAsString();
int result = strcmp(str1.c_str(), str2.c_str());
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,result));
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,result));
ci->eraseFromParent();
return true;
}
@@ -698,7 +698,7 @@ public:
/// @brief Make sure that the "strncmp" function has the right prototype
virtual bool ValidateCalledFunction(const Function* f, SimplifyLibCalls& SLC){
- if (f->getReturnType() == Type::IntTy && f->arg_size() == 3)
+ if (f->getReturnType() == Type::Int32Ty && f->arg_size() == 3)
return true;
return false;
}
@@ -712,7 +712,7 @@ public:
Value* s2 = ci->getOperand(2);
if (s1 == s2) {
// strncmp(x,x,l) -> 0
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,0));
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,0));
ci->eraseFromParent();
return true;
}
@@ -726,7 +726,7 @@ public:
len_arg = len_CI->getZExtValue();
if (len_arg == 0) {
// strncmp(x,y,0) -> 0
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,0));
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,0));
ci->eraseFromParent();
return true;
}
@@ -741,7 +741,7 @@ public:
// strncmp("",x) -> *x
LoadInst* load = new LoadInst(s1,ci->getName()+".load",ci);
CastInst* cast =
- CastInst::create(Instruction::SExt, load, Type::IntTy,
+ CastInst::create(Instruction::SExt, load, Type::Int32Ty,
ci->getName()+".int", ci);
ci->replaceAllUsesWith(cast);
ci->eraseFromParent();
@@ -758,7 +758,7 @@ public:
// strncmp(x,"") -> *x
LoadInst* load = new LoadInst(s2,ci->getName()+".val",ci);
CastInst* cast =
- CastInst::create(Instruction::SExt, load, Type::IntTy,
+ CastInst::create(Instruction::SExt, load, Type::Int32Ty,
ci->getName()+".int", ci);
ci->replaceAllUsesWith(cast);
ci->eraseFromParent();
@@ -771,7 +771,7 @@ public:
std::string str1 = A1->getAsString();
std::string str2 = A2->getAsString();
int result = strncmp(str1.c_str(), str2.c_str(), len_arg);
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,result));
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,result));
ci->eraseFromParent();
return true;
}
@@ -791,11 +791,11 @@ public:
/// @brief Make sure that the "strcpy" function has the right prototype
virtual bool ValidateCalledFunction(const Function* f, SimplifyLibCalls& SLC){
- if (f->getReturnType() == PointerType::get(Type::SByteTy))
+ if (f->getReturnType() == PointerType::get(Type::Int8Ty))
if (f->arg_size() == 2) {
Function::const_arg_iterator AI = f->arg_begin();
- if (AI++->getType() == PointerType::get(Type::SByteTy))
- if (AI->getType() == PointerType::get(Type::SByteTy)) {
+ if (AI++->getType() == PointerType::get(Type::Int8Ty))
+ if (AI->getType() == PointerType::get(Type::Int8Ty)) {
// Indicate this is a suitable call type.
return true;
}
@@ -830,7 +830,7 @@ public:
// If the constant string's length is zero we can optimize this by just
// doing a store of 0 at the first byte of the destination
if (len == 0) {
- new StoreInst(ConstantInt::get(Type::SByteTy,0),ci->getOperand(1),ci);
+ new StoreInst(ConstantInt::get(Type::Int8Ty,0),ci->getOperand(1),ci);
ci->replaceAllUsesWith(dest);
ci->eraseFromParent();
return true;
@@ -846,7 +846,7 @@ public:
vals.push_back(dest); // destination
vals.push_back(src); // source
vals.push_back(ConstantInt::get(SLC.getIntPtrType(),len)); // length
- vals.push_back(ConstantInt::get(Type::UIntTy,1)); // alignment
+ vals.push_back(ConstantInt::get(Type::Int32Ty,1)); // alignment
new CallInst(SLC.get_memcpy(), vals, "", ci);
// Finally, substitute the first operand of the strcat call for the
@@ -872,7 +872,7 @@ struct StrLenOptimization : public LibCallOptimization {
if (f->getReturnType() == SLC.getTargetData()->getIntPtrType())
if (f->arg_size() == 1)
if (Function::const_arg_iterator AI = f->arg_begin())
- if (AI->getType() == PointerType::get(Type::SByteTy))
+ if (AI->getType() == PointerType::get(Type::Int8Ty))
return true;
return false;
}
@@ -882,7 +882,7 @@ struct StrLenOptimization : public LibCallOptimization {
{
// Make sure we're dealing with an sbyte* here.
Value* str = ci->getOperand(1);
- if (str->getType() != PointerType::get(Type::SByteTy))
+ if (str->getType() != PointerType::get(Type::Int8Ty))
return false;
// Does the call to strlen have exactly one use?
@@ -904,7 +904,7 @@ struct StrLenOptimization : public LibCallOptimization {
// strlen(x) == 0 -> *x == 0
LoadInst* load = new LoadInst(str,str->getName()+".first",ci);
ICmpInst* rbop = new ICmpInst(bop->getPredicate(), load,
- ConstantInt::get(Type::SByteTy,0),
+ ConstantInt::get(Type::Int8Ty,0),
bop->getName()+".strlen", ci);
bop->replaceAllUsesWith(rbop);
bop->eraseFromParent();
@@ -996,7 +996,7 @@ struct memcmpOptimization : public LibCallOptimization {
return true;
case 1: {
// memcmp(S1,S2,1) -> *(ubyte*)S1 - *(ubyte*)S2
- const Type *UCharPtr = PointerType::get(Type::UByteTy);
+ const Type *UCharPtr = PointerType::get(Type::Int8Ty);
CastInst *Op1Cast = CastInst::create(
Instruction::BitCast, LHS, UCharPtr, LHS->getName(), CI);
CastInst *Op2Cast = CastInst::create(
@@ -1016,7 +1016,7 @@ struct memcmpOptimization : public LibCallOptimization {
// TODO: IF both are aligned, use a short load/compare.
// memcmp(S1,S2,2) -> S1[0]-S2[0] | S1[1]-S2[1] iff only ==/!= 0 matters
- const Type *UCharPtr = PointerType::get(Type::UByteTy);
+ const Type *UCharPtr = PointerType::get(Type::Int8Ty);
CastInst *Op1Cast = CastInst::create(
Instruction::BitCast, LHS, UCharPtr, LHS->getName(), CI);
CastInst *Op2Cast = CastInst::create(
@@ -1025,7 +1025,7 @@ struct memcmpOptimization : public LibCallOptimization {
Value *S2V1 = new LoadInst(Op2Cast, RHS->getName()+".val1", CI);
Value *D1 = BinaryOperator::createSub(S1V1, S2V1,
CI->getName()+".d1", CI);
- Constant *One = ConstantInt::get(Type::IntTy, 1);
+ Constant *One = ConstantInt::get(Type::Int32Ty, 1);
Value *G1 = new GetElementPtrInst(Op1Cast, One, "next1v", CI);
Value *G2 = new GetElementPtrInst(Op2Cast, One, "next2v", CI);
Value *S1V2 = new LoadInst(G1, LHS->getName()+".val2", CI);
@@ -1098,10 +1098,10 @@ struct LLVMMemCpyMoveOptzn : public LibCallOptimization {
// memcpy(d,s,0,a) -> noop
ci->eraseFromParent();
return true;
- case 1: castType = Type::SByteTy; break;
- case 2: castType = Type::ShortTy; break;
- case 4: castType = Type::IntTy; break;
- case 8: castType = Type::LongTy; break;
+ case 1: castType = Type::Int8Ty; break;
+ case 2: castType = Type::Int16Ty; break;
+ case 4: castType = Type::Int32Ty; break;
+ case 8: castType = Type::Int64Ty; break;
default:
return false;
}
@@ -1183,7 +1183,7 @@ struct LLVMMemSetOptimization : public LibCallOptimization {
ConstantInt* FILL = dyn_cast<ConstantInt>(ci->getOperand(2));
if (!FILL)
return false;
- if (FILL->getType() != Type::UByteTy)
+ if (FILL->getType() != Type::Int8Ty)
return false;
// memset(s,c,n) -> store s, c (for n=1,2,4,8)
@@ -1198,18 +1198,18 @@ struct LLVMMemSetOptimization : public LibCallOptimization {
Type* castType = 0;
switch (len) {
case 1:
- castType = Type::UByteTy;
+ castType = Type::Int8Ty;
break;
case 2:
- castType = Type::UShortTy;
+ castType = Type::Int16Ty;
fill_value |= fill_char << 8;
break;
case 4:
- castType = Type::UIntTy;
+ castType = Type::Int32Ty;
fill_value |= fill_char << 8 | fill_char << 16 | fill_char << 24;
break;
case 8:
- castType = Type::ULongTy;
+ castType = Type::Int64Ty;
fill_value |= fill_char << 8 | fill_char << 16 | fill_char << 24;
fill_value |= fill_char << 32 | fill_char << 40 | fill_char << 48;
fill_value |= fill_char << 56;
@@ -1350,7 +1350,7 @@ public:
std::vector<Value*> args;
args.push_back(CastToCStr(ci->getOperand(2), *ci));
new CallInst(puts_func,args,ci->getName(),ci);
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len));
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,len));
break;
}
case 'c':
@@ -1363,9 +1363,9 @@ public:
if (!putchar_func)
return false;
CastInst* cast = CastInst::createSExtOrBitCast(
- ci->getOperand(2), Type::IntTy, CI->getName()+".int", ci);
+ ci->getOperand(2), Type::Int32Ty, CI->getName()+".int", ci);
new CallInst(putchar_func, cast, "", ci);
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy, 1));
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty, 1));
break;
}
default:
@@ -1440,7 +1440,7 @@ public:
args.push_back(ConstantInt::get(SLC.getIntPtrType(),1));
args.push_back(ci->getOperand(1));
new CallInst(fwrite_func,args,ci->getName(),ci);
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len));
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,len));
ci->eraseFromParent();
return true;
}
@@ -1474,7 +1474,7 @@ public:
args.push_back(ConstantInt::get(SLC.getIntPtrType(),1));
args.push_back(ci->getOperand(1));
new CallInst(fwrite_func,args,ci->getName(),ci);
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len));
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,len));
} else {
// fprintf(file,"%s",str) -> fputs(str,file)
const Type* FILEptr_type = ci->getOperand(1)->getType();
@@ -1485,7 +1485,7 @@ public:
args.push_back(CastToCStr(ci->getOperand(3), *ci));
args.push_back(ci->getOperand(1));
new CallInst(fputs_func,args,ci->getName(),ci);
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len));
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,len));
}
break;
}
@@ -1497,9 +1497,9 @@ public:
if (!fputc_func)
return false;
CastInst* cast = CastInst::createSExtOrBitCast(
- ci->getOperand(3), Type::IntTy, CI->getName()+".int", ci);
+ ci->getOperand(3), Type::Int32Ty, CI->getName()+".int", ci);
new CallInst(fputc_func,cast,ci->getOperand(1),"",ci);
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,1));
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,1));
break;
}
default:
@@ -1523,7 +1523,7 @@ public:
/// @brief Make sure that the "fprintf" function has the right prototype
virtual bool ValidateCalledFunction(const Function *f, SimplifyLibCalls &SLC){
// Just make sure this has at least 2 arguments
- return (f->getReturnType() == Type::IntTy && f->arg_size() >= 2);
+ return (f->getReturnType() == Type::Int32Ty && f->arg_size() >= 2);
}
/// @brief Perform the sprintf optimization.
@@ -1542,8 +1542,8 @@ public:
if (ci->getNumOperands() == 3) {
if (len == 0) {
// If the length is 0, we just need to store a null byte
- new StoreInst(ConstantInt::get(Type::SByteTy,0),ci->getOperand(1),ci);
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,0));
+ new StoreInst(ConstantInt::get(Type::Int8Ty,0),ci->getOperand(1),ci);
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,0));
ci->eraseFromParent();
return true;
}
@@ -1570,9 +1570,9 @@ public:
args.push_back(ci->getOperand(1));
args.push_back(ci->getOperand(2));
args.push_back(ConstantInt::get(SLC.getIntPtrType(),len));
- args.push_back(ConstantInt::get(Type::UIntTy,1));
+ args.push_back(ConstantInt::get(Type::Int32Ty,1));
new CallInst(memcpy_func,args,"",ci);
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len));
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,len));
ci->eraseFromParent();
return true;
}
@@ -1609,7 +1609,7 @@ public:
args.push_back(CastToCStr(ci->getOperand(1), *ci));
args.push_back(CastToCStr(ci->getOperand(3), *ci));
args.push_back(Len1);
- args.push_back(ConstantInt::get(Type::UIntTy,1));
+ args.push_back(ConstantInt::get(Type::Int32Ty,1));
new CallInst(memcpy_func, args, "", ci);
// The strlen result is the unincremented number of bytes in the string.
@@ -1625,13 +1625,13 @@ public:
case 'c': {
// sprintf(dest,"%c",chr) -> store chr, dest
CastInst* cast = CastInst::createTruncOrBitCast(
- ci->getOperand(3), Type::SByteTy, "char", ci);
+ ci->getOperand(3), Type::Int8Ty, "char", ci);
new StoreInst(cast, ci->getOperand(1), ci);
GetElementPtrInst* gep = new GetElementPtrInst(ci->getOperand(1),
- ConstantInt::get(Type::UIntTy,1),ci->getOperand(1)->getName()+".end",
+ ConstantInt::get(Type::Int32Ty,1),ci->getOperand(1)->getName()+".end",
ci);
- new StoreInst(ConstantInt::get(Type::SByteTy,0),gep,ci);
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,1));
+ new StoreInst(ConstantInt::get(Type::Int8Ty,0),gep,ci);
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,1));
ci->eraseFromParent();
return true;
}
@@ -1681,7 +1681,7 @@ public:
return false;
LoadInst* loadi = new LoadInst(ci->getOperand(1),
ci->getOperand(1)->getName()+".byte",ci);
- CastInst* casti = new SExtInst(loadi, Type::IntTy,
+ CastInst* casti = new SExtInst(loadi, Type::Int32Ty,
loadi->getName()+".int", ci);
new CallInst(fputc_func,casti,ci->getOperand(2),"",ci);
break;
@@ -1727,23 +1727,23 @@ public:
// isdigit(c) -> 0 or 1, if 'c' is constant
uint64_t val = CI->getZExtValue();
if (val >= '0' && val <='9')
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,1));
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,1));
else
- ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,0));
+ ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,0));
ci->eraseFromParent();
return true;
}
// isdigit(c) -> (unsigned)c - '0' <= 9
CastInst* cast = CastInst::createIntegerCast(ci->getOperand(1),
- Type::UIntTy, false/*ZExt*/, ci->getOperand(1)->getName()+".uint", ci);
+ Type::Int32Ty, false/*ZExt*/, ci->getOperand(1)->getName()+".uint", ci);
BinaryOperator* sub_inst = BinaryOperator::createSub(cast,
- ConstantInt::get(Type::UIntTy,0x30),
+ ConstantInt::get(Type::Int32Ty,0x30),
ci->getOperand(1)->getName()+".sub",ci);
ICmpInst* setcond_inst = new ICmpInst(ICmpInst::ICMP_ULE,sub_inst,
- ConstantInt::get(Type::UIntTy,9),
+ ConstantInt::get(Type::Int32Ty,9),
ci->getOperand(1)->getName()+".cmp",ci);
- CastInst* c2 = new ZExtInst(setcond_inst, Type::IntTy,
+ CastInst* c2 = new ZExtInst(setcond_inst, Type::Int32Ty,
ci->getOperand(1)->getName()+".isdigit", ci);
ci->replaceAllUsesWith(c2);
ci->eraseFromParent();
@@ -1824,7 +1824,7 @@ public:
/// @brief Make sure that the "ffs" function has the right prototype
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
// Just make sure this has 2 arguments
- return F->arg_size() == 1 && F->getReturnType() == Type::IntTy;
+ return F->arg_size() == 1 && F->getReturnType() == Type::Int32Ty;
}
/// @brief Perform the ffs optimization.
@@ -1842,7 +1842,7 @@ public:
val >>= 1;
}
}
- TheCall->replaceAllUsesWith(ConstantInt::get(Type::IntTy, result));
+ TheCall->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty, result));
TheCall->eraseFromParent();
return true;
}
@@ -1851,14 +1851,13 @@ public:
// ffsl(x) -> x == 0 ? 0 : llvm.cttz(x)+1
// ffsll(x) -> x == 0 ? 0 : llvm.cttz(x)+1
const Type *ArgType = TheCall->getOperand(1)->getType();
- ArgType = ArgType->getUnsignedVersion();
const char *CTTZName;
switch (ArgType->getTypeID()) {
default: assert(0 && "Unknown unsigned type!");
- case Type::UByteTyID : CTTZName = "llvm.cttz.i8" ; break;
- case Type::UShortTyID: CTTZName = "llvm.cttz.i16"; break;
- case Type::UIntTyID : CTTZName = "llvm.cttz.i32"; break;
- case Type::ULongTyID : CTTZName = "llvm.cttz.i64"; break;
+ case Type::Int8TyID : CTTZName = "llvm.cttz.i8" ; break;
+ case Type::Int16TyID: CTTZName = "llvm.cttz.i16"; break;
+ case Type::Int32TyID : CTTZName = "llvm.cttz.i32"; break;
+ case Type::Int64TyID : CTTZName = "llvm.cttz.i64"; break;
}
Function *F = SLC.getModule()->getOrInsertFunction(CTTZName, ArgType,
@@ -1866,14 +1865,14 @@ public:
Value *V = CastInst::createIntegerCast(TheCall->getOperand(1), ArgType,
false/*ZExt*/, "tmp", TheCall);
Value *V2 = new CallInst(F, V, "tmp", TheCall);
- V2 = CastInst::createIntegerCast(V2, Type::IntTy, false/*ZExt*/,
+ V2 = CastInst::createIntegerCast(V2, Type::Int32Ty, false/*ZExt*/,
"tmp", TheCall);
- V2 = BinaryOperator::createAdd(V2, ConstantInt::get(Type::IntTy, 1),
+ V2 = BinaryOperator::createAdd(V2, ConstantInt::get(Type::Int32Ty, 1),
"tmp", TheCall);
Value *Cond = new ICmpInst(ICmpInst::ICMP_EQ, V,
Constant::getNullValue(V->getType()), "tmp",
TheCall);
- V2 = new SelectInst(Cond, ConstantInt::get(Type::IntTy, 0), V2,
+ V2 = new SelectInst(Cond, ConstantInt::get(Type::Int32Ty, 0), V2,
TheCall->getName(), TheCall);
TheCall->replaceAllUsesWith(V2);
TheCall->eraseFromParent();
@@ -2112,7 +2111,7 @@ bool getConstantStringLength(Value *V, uint64_t &len, ConstantArray **CA) {
Value *CastToCStr(Value *V, Instruction &IP) {
assert(isa<PointerType>(V->getType()) &&
"Can't cast non-pointer type to C string type");
- const Type *SBPTy = PointerType::get(Type::SByteTy);
+ const Type *SBPTy = PointerType::get(Type::Int8Ty);
if (V->getType() != SBPTy)
return new BitCastInst(V, SBPTy, V->getName(), &IP);
return V;
diff --git a/lib/Transforms/Instrumentation/BlockProfiling.cpp b/lib/Transforms/Instrumentation/BlockProfiling.cpp
index af438f9655..e7b86777cf 100644
--- a/lib/Transforms/Instrumentation/BlockProfiling.cpp
+++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp
@@ -57,7 +57,7 @@ bool FunctionProfiler::runOnModule(Module &M) {
if (!I->isExternal())
++NumFunctions;
- const Type *ATy = ArrayType::get(Type::UIntTy, NumFunctions);
+ const Type *ATy = ArrayType::get(Type::Int32Ty, NumFunctions);
GlobalVariable *Counters =
new GlobalVariable(ATy, false, GlobalValue::InternalLinkage,
Constant::getNullValue(ATy), "FuncProfCounters", &M);
@@ -99,7 +99,7 @@ bool BlockProfiler::runOnModule(Module &M) {
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
NumBlocks += I->size();
- const Type *ATy = ArrayType::get(Type::UIntTy, NumBlocks);
+ const Type *ATy = ArrayType::get(Type::Int32Ty, NumBlocks);
GlobalVariable *Counters =
new GlobalVariable(ATy, false, GlobalValue::InternalLinkage,
Constant::getNullValue(ATy), "BlockProfCounters", &M);
diff --git a/lib/Transforms/Instrumentation/EdgeProfiling.cpp b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
index 36cf3e9430..97b5d5ca42 100644
--- a/lib/Transforms/Instrumentation/EdgeProfiling.cpp
+++ b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
@@ -58,7 +58,7 @@ bool EdgeProfiler::runOnModule(Module &M) {
NumEdges += BB->getTerminator()->getNumSuccessors();
}
- const Type *ATy = ArrayType::get(Type::UIntTy, NumEdges);
+ const Type *ATy = ArrayType::get(Type::Int32Ty, NumEdges);
GlobalVariable *Counters =
new GlobalVariable(ATy, false, GlobalValue::InternalLinkage,
Constant::getNullValue(ATy), "EdgeProfCounters", &M);
diff --git a/lib/Transforms/Instrumentation/EmitFunctions.cpp b/lib/Transforms/Instrumentation/EmitFunctions.cpp
index b4523257af..23fa4faaad 100644
--- a/lib/Transforms/Instrumentation/EmitFunctions.cpp
+++ b/lib/Transforms/Instrumentation/EmitFunctions.cpp
@@ -87,7 +87,7 @@ bool EmitFunctionTable::runOnModule(Module &M){
//std::cerr<<MI;
vConsts.push_back(MI);
- sBCons.push_back(ConstantInt::get(Type::SByteTy, hasBackEdge(MI)));
+ sBCons.push_back(ConstantInt::get(Type::Int8Ty, hasBackEdge(MI)));
counter++;
}
@@ -100,7 +100,7 @@ bool EmitFunctionTable::runOnModule(Module &M){
cstruct, "llvmFunctionTable");
M.getGlobalList().push_back(gb);
- Constant *constArray = ConstantArray::get(ArrayType::get(Type::SByteTy,
+ Constant *constArray = ConstantArray::get(ArrayType::get(Type::Int8Ty,
sBCons.size()),
sBCons);
@@ -110,8 +110,8 @@ bool EmitFunctionTable::runOnModule(Module &M){
M.getGlobalList().push_back(funcArray);
- ConstantInt *cnst = ConstantInt::get(Type::IntTy, counter);
- GlobalVariable *fnCount = new GlobalVariable(Type::IntTy, true,
+ ConstantInt *cnst = ConstantInt::get(Type::Int32Ty, counter);
+ GlobalVariable *fnCount = new GlobalVariable(Type::Int32Ty, true,
GlobalValue::ExternalLinkage,
cnst, "llvmFunctionCount");
M.getGlobalList().push_back(fnCount);
diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp
index 4068392884..1df7001488 100644
--- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp
+++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp
@@ -22,17 +22,17 @@
void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
GlobalValue *Array) {
- const Type *ArgVTy = PointerType::get(PointerType::get(Type::SByteTy));
- const PointerType *UIntPtr = PointerType::get(Type::UIntTy);
+ const Type *ArgVTy = PointerType::get(PointerType::get(Type::Int8Ty));
+ const PointerType *UIntPtr = PointerType::get(Type::Int32Ty);
Module &M = *MainFn->getParent();
- Function *InitFn = M.getOrInsertFunction(FnName, Type::IntTy, Type::IntTy,
- ArgVTy, UIntPtr, Type::UIntTy,
+ Function *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty,
+ ArgVTy, UIntPtr, Type::Int32Ty,
(Type *)0);
// This could force argc and argv into programs that wouldn't otherwise have
// them, but instead we just pass null values in.
std::vector<Value*> Args(4);
- Args[0] = Constant::getNullValue(Type::IntTy);
+ Args[0] = Constant::getNullValue(Type::Int32Ty);
Args[1] = Constant::getNullValue(ArgVTy);
// Skip over any allocas in the entry block.
@@ -40,7 +40,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
BasicBlock::iterator InsertPos = Entry->begin();
while (isa<AllocaInst>(InsertPos)) ++InsertPos;
- std::vector<Constant*> GEPIndices(2, Constant::getNullValue(Type::IntTy));
+ std::vector<Constant*> GEPIndices(2, Constant::getNullValue(Type::Int32Ty));
unsigned NumElements = 0;
if (Array) {
Args[2] = ConstantExpr::getGetElementPtr(Array, GEPIndices);
@@ -51,7 +51,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
// pass null.
Args[2] = ConstantPointerNull::get(UIntPtr);
}
- Args[3] = ConstantInt::get(Type::UIntTy, NumElements);
+ Args[3] = ConstantInt::get(Type::Int32Ty, NumElements);
Instruction *InitCall = new CallInst(InitFn, Args, "newargc", InsertPos);
@@ -75,16 +75,16 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
AI = MainFn->arg_begin();
// If the program looked at argc, have it look at the return value of the
// init call instead.
- if (AI->getType() != Type::IntTy) {
+ if (AI->getType() != Type::Int32Ty) {
Instruction::CastOps opcode;
if (!AI->use_empty()) {
opcode = CastInst::getCastOpcode(InitCall, true, AI->getType(), true);
AI->replaceAllUsesWith(
CastInst::create(opcode, InitCall, AI->getType(), "", InsertPos));
}
- opcode = CastInst::getCastOpcode(AI, true, Type::IntTy, true);
+ opcode = CastInst::getCastOpcode(AI, true, Type::Int32Ty, true);
InitCall->setOperand(1,
- CastInst::create(opcode, AI, Type::IntTy, "argc.cast", InitCall));
+ CastInst::create(opcode, AI, Type::Int32Ty, "argc.cast", InitCall));
} else {
AI->replaceAllUsesWith(InitCall);
InitCall->setOperand(1, AI);
@@ -103,14 +103,14 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum,
// Create the getelementptr constant expression
std::vector<Constant*> Indices(2);
- Indices[0] = Constant::getNullValue(Type::IntTy);
- Indices[1] = ConstantInt::get(Type::IntTy, CounterNum);
+ Indices[0] = Constant::getNullValue(Type::Int32Ty);
+ Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum);
Constant *ElementPtr = ConstantExpr::getGetElementPtr(CounterArray, Indices);
// Load, increment and store the value back.
Value *OldVal = new LoadInst(ElementPtr, "OldFuncCounter", InsertPos);
Value *NewVal = BinaryOperator::create(Instruction::Add, OldVal,
- ConstantInt::get(Type::UIntTy, 1),
+ ConstantInt::get(Type::Int32Ty, 1),
"NewFuncCounter", InsertPos);
new StoreInst(NewVal, ElementPtr, InsertPos);
}
diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp
index b18d66befb..1553141cec 100644
--- a/lib/Transforms/Instrumentation/RSProfiling.cpp
+++ b/lib/Transforms/Instrumentation/RSProfiling.cpp
@@ -290,7 +290,7 @@ void GlobalRandomCounterOpt::ProcessChoicePoint(BasicBlock* bb) {
CycleCounter::CycleCounter(Module& m, uint64_t resetmask) : rm(resetmask) {
- F = m.getOrInsertFunction("llvm.readcyclecounter", Type::ULongTy, NULL);
+ F = m.getOrInsertFunction("llvm.readcyclecounter", Type::Int64Ty, NULL);
}
CycleCounter::~CycleCounter() {}
@@ -302,11 +302,11 @@ void CycleCounter::ProcessChoicePoint(BasicBlock* bb) {
CallInst* c = new CallInst(F, "rdcc", t);
BinaryOperator* b =
- BinaryOperator::createAnd(c, ConstantInt::get(Type::ULongTy, rm),
+ BinaryOperator::createAnd(c, ConstantInt::get(Type::Int64Ty, rm),
"mrdcc", t);
ICmpInst *s = new ICmpInst(ICmpInst::ICMP_EQ, b,
- ConstantInt::get(Type::ULongTy, 0),
+ ConstantInt::get(Type::Int64Ty, 0),
"mrdccc", t);
t->setCondition(s);
@@ -332,15 +332,15 @@ void RSProfilers_std::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNu
// Create the getelementptr constant expression
std::vector<Constant*> Indices(2);
- Indices[0] = Constant::getNullValue(Type::IntTy);
- Indices[1] = ConstantInt::get(Type::IntTy, CounterNum);
+ Indices[0] = Constant::getNullValue(Type::Int32Ty);
+ Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum);
Constant *ElementPtr = ConstantExpr::getGetElementPtr(CounterArray, Indices);
// Load, increment and store the value back.
Value *OldVal = new LoadInst(ElementPtr, "OldCounter", InsertPos);
profcode.insert(OldVal);
Value *NewVal = BinaryOperator::createAdd(OldVal,
- ConstantInt::get(Type::UIntTy, 1),
+ ConstantInt::get(Type::Int32Ty, 1),
"NewCounter", InsertPos);
profcode.insert(NewVal);
profcode.insert(new StoreInst(NewVal, ElementPtr, InsertPos));
@@ -539,10 +539,10 @@ bool ProfilerRS::runOnFunction(Function& F) {
bool ProfilerRS::doInitialization(Module &M) {
switch (RandomMethod) {
case GBV:
- c = new GlobalRandomCounter(M, Type::UIntTy, (1 << 14) - 1);
+ c = new GlobalRandomCounter(M, Type::Int32Ty, (1 << 14) - 1);
break;
case GBVO:
- c = new GlobalRandomCounterOpt(M, Type::UIntTy, (1 << 14) - 1);
+ c = new GlobalRandomCounterOpt(M, Type::Int32Ty, (1 << 14) - 1);
break;
case HOSTCC:
c = new CycleCounter(M, (1 << 14) - 1);
diff --git a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp
index 10b3641978..379005359d 100644
--- a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp
+++ b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp
@@ -46,9 +46,9 @@ static void InsertInstrumentationCall (BasicBlock *BB,
<< "\", \"" << FnName << "\", " << BBNumber << ")\n";
Module &M = *BB->getParent ()->getParent ();
Function *InstrFn = M.getOrInsertFunction (FnName, Type::VoidTy,
- Type::UIntTy, (Type *)0);
+ Type::Int32Ty, (Type *)0);
std::vector<Value*> Args (1);
- Args[0] = ConstantInt::get (Type::UIntTy, BBNumber);
+ Args[0] = ConstantInt::get (Type::Int32Ty, BBNumber);
// Insert the call after any alloca or PHI instructions...
BasicBlock::iterator InsertPos = BB->begin();
diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp
index f6048f140d..9fbec118c2 100644
--- a/lib/Transforms/Instrumentation/TraceValues.cpp
+++ b/lib/Transforms/Instrumentation/TraceValues.cpp
@@ -123,13 +123,13 @@ FunctionPass *llvm::createTraceValuesPassForBasicBlocks() {
//
void ExternalFuncs::doInitialization(Module &M) {
M.addLibrary("trace");
- const Type *SBP = PointerType::get(Type::SByteTy);
+ const Type *SBP = PointerType::get(Type::Int8Ty);
const FunctionType *MTy =
- FunctionType::get(Type::IntTy, std::vector<const Type*>(1, SBP), true);
+ FunctionType::get(Type::Int32Ty, std::vector<const Type*>(1, SBP), true);
PrintfFunc = M.getOrInsertFunction("printf", MTy);
// uint (sbyte*)
- HashPtrFunc = M.getOrInsertFunction("HashPointerToSeqNum", Type::UIntTy, SBP,
+ HashPtrFunc = M.getOrInsertFunction("HashPointerToSeqNum", Type::Int32Ty, SBP,
(Type *)0);
// void (sbyte*)
@@ -244,11 +244,11 @@ static void InsertPrintInst(Value *V, BasicBlock *BB, Instruction *InsertBefore,
// Turn the format string into an sbyte *
Constant *GEP=ConstantExpr::getGetElementPtr(fmtVal,
- std::vector<Constant*>(2,Constant::getNullValue(Type::LongTy)));
+ std::vector<Constant*>(2,Constant::getNullValue(Type::Int64Ty)));
// Insert a call to the hash function if this is a pointer value
if (V && isa<PointerType>(V->getType()) && !DisablePtrHashing) {
- const Type *SBP = PointerType::get(Type::SByteTy);
+ const Type *SBP = PointerType::get(Type::Int8Ty);
if (V->getType() != SBP) // Cast pointer to be sbyte*
V = new BitCastInst(V, SBP, "Hash_cast", InsertBefore);
@@ -279,7 +279,7 @@ InsertReleaseInst(Value *V, BasicBlock *BB,
Instruction *InsertBefore,
Function* ReleasePtrFunc) {
- const Type *SBP = PointerType::get(Type::SByteTy);
+ const Type *SBP = PointerType::get(Type::Int8Ty);
if (V->getType() != SBP) // Cast pointer to be sbyte*
V = new BitCastInst(V, SBP, "RPSN_cast", InsertBefore);
@@ -291,7 +291,7 @@ static void
InsertRecordInst(Value *V, BasicBlock *BB,
Instruction *InsertBefore,
Function* RecordPtrFunc) {
- const Type *SBP = PointerType::get(Type::SByteTy);
+ const Type *SBP = PointerType::get(Type::Int8Ty);
if (V->getType() != SBP) // Cast pointer to be sbyte*
V = new BitCastInst(V, SBP, "RP_cast", InsertBefore);
diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp
index f0d39155a3..4ebf25b49c 100644
--- a/lib/Transforms/LevelRaise.cpp
+++ b/lib/Transforms/LevelRaise.cpp
@@ -206,7 +206,7 @@ bool RPR::PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
// Build the index vector, full of all zeros
std::vector<Value*> Indices;
- Indices.push_back(Constant::getNullValue(Type::UIntTy));
+ Indices.push_back(Constant::getNullValue(Type::Int32Ty));
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.
@@ -221,7 +221,7 @@ bool RPR::PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
}
// Insert a zero to index through this type...
- Indices.push_back(Constant::getNullValue(Type::UIntTy));
+ Indices.push_back(Constant::getNullValue(Type::Int32Ty));
// Did we find what we're looking for?
if (ElTy->canLosslesslyBitCastTo(DestPointedTy)) break;
diff --git a/lib/Transforms/Scalar/CorrelatedExprs.cpp b/lib/Transforms/Scalar/CorrelatedExprs.cpp
index 8d369f2870..ee220d19e5 100644
--- a/lib/Transforms/Scalar/CorrelatedExprs.cpp
+++ b/lib/Transforms/Scalar/CorrelatedExprs.cpp
@@ -111,7 +111,7 @@ namespace {
Value *Replacement;
public:
ValueInfo(const Type *Ty)
- : Bounds(Ty->isIntegral() ? Ty : Type::IntTy), Replacement(0) {}
+ : Bounds(Ty->isIntegral() ? Ty : Type::Int32Ty), Replacement(0) {}
// getBounds() - Return the constant bounds of the value...
const ConstantRange &getBounds() const { return Bounds; }
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp
index fac17d1c8c..143a6828a2 100644
--- a/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -173,7 +173,7 @@ void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN,
Constant *NCE = ConstantExpr::getGetElementPtr(CE->getOperand(0),
CEIdxs);
GetElementPtrInst *NGEPI =
- new GetElementPtrInst(NCE, Constant::getNullValue(Type::IntTy),
+ new GetElementPtrInst(NCE, Constant::getNullValue(Type::Int32Ty),
NewAdd, GEPI->getName(), GEPI);
GEPI->replaceAllUsesWith(NGEPI);
GEPI->eraseFromParent();
@@ -499,7 +499,6 @@ void IndVarSimplify::runOnLoop(Loop *L) {
// Now that we know the largest of of the induction variables in this loop,
// insert a canonical induction variable of the largest size.
- LargestType = LargestType->getUnsignedVersion();
Value *IndVar = Rewriter.getOrInsertCanonicalInductionVariable(L,LargestType);
++NumInserted;
Changed = true;
@@ -525,7 +524,7 @@ void IndVarSimplify::runOnLoop(Loop *L) {
PHINode *PN = IndVars[i].first;
InsertedSizes[PN->getType()->getPrimitiveSize()] = true;
Instruction *New = CastInst::create(Instruction::Trunc, IndVar,
- PN->getType()->getUnsignedVersion(), "indvar", InsertPt);
+ PN->getType(), "indvar", InsertPt);
Rewriter.addInsertedValue(New, SE->getSCEV(New));
}
}
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 592e61d040..c78c01a950 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -340,10 +340,8 @@ static bool isOnlyUse(Value *V) {
// though a va_arg area...
static const Type *getPromotedType(const Type *Ty) {
switch (Ty->getTypeID()) {
- case Type::SByteTyID:
- case Type::ShortTyID: return Type::IntTy;
- case Type::UByteTyID:
- case Type::UShortTyID: return Type::UIntTy;
+ case Type::Int8TyID:
+ case Type::Int16TyID: return Type::Int32Ty;
case Type::FloatTyID: return Type::DoubleTy;
default: return Ty;
}
@@ -540,14 +538,9 @@ static ConstantInt *SubOne(ConstantInt *C) {
/// GetConstantInType - Return a ConstantInt with the specified type and value.
///
static ConstantIntegral *GetConstantInType(const Type *Ty, uint64_t Val) {
- if (Ty->isUnsigned())
- return ConstantInt::get(Ty, Val);
- else if (Ty->getTypeID() == Type::BoolTyID)
+ if (Ty->getTypeID() == Type::BoolTyID)
return ConstantBool::get(Val);
- int64_t SVal = Val;
- SVal <<= 64-Ty->getPrimitiveSizeInBits();
- SVal >>= 64-Ty->getPrimitiveSizeInBits();
- return ConstantInt::get(Ty, SVal);
+ return ConstantInt::get(Ty, Val);
}
@@ -1575,7 +1568,7 @@ struct AddRHS {
bool shouldApply(Value *LHS) const { return LHS == RHS; }
Instruction *apply(BinaryOperator &Add) const {
return new ShiftInst(Instruction::Shl, Add.getOperand(0),
- ConstantInt::get(Type::UByteTy, 1));
+ ConstantInt::get(Type::Int8Ty, 1));
}
};
@@ -1825,9 +1818,9 @@ FoundSExt:
const Type *MiddleType = 0;
switch (Size) {
default: break;
- case 32: MiddleType = Type::IntTy; break;
- case 16: MiddleType = Type::ShortTy; break;
- case 8: MiddleType = Type::SByteTy; break;
+ case 32: MiddleType = Type::Int32Ty; break;
+ case 16: MiddleType = Type::Int16Ty; break;
+ case 8: MiddleType = Type::Int8Ty; break;
}
if (MiddleType) {
Instruction *NewTrunc = new TruncInst(XorLHS, MiddleType, "sext");
@@ -1935,7 +1928,7 @@ FoundSExt:
TD->getIntPtrType()->getPrimitiveSize())
&& isa<PointerType>(CI->getOperand(0)->getType())) {
Value *I2 = InsertCastBefore(Instruction::BitCast, CI->getOperand(0),
- PointerType::get(Type::SByteTy), I);
+ PointerType::get(Type::Int8Ty), I);
I2 = InsertNewInstBefore(new GetElementPtrInst(I2, Other, "ctg2"), I);
return new PtrToIntInst(I2, CI->getType());
}
@@ -2018,9 +2011,10 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
// Check to see if we are shifting out everything but the sign bit.
if (CU->getZExtValue() ==
SI->getType()->getPrimitiveSizeInBits()-1) {
- // Ok, the transformation is safe. Insert LShr.
- return new ShiftInst(Instruction::LShr, SI->getOperand(0),
- CU, SI->getName());
+
+ // Ok, the transformation is safe. Insert LShr.
+ return new ShiftInst(Instruction::LShr, SI->getOperand(0), CU,
+ SI->getName());
}
}
}
@@ -2173,7 +2167,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
if (isPowerOf2_64(Val)) { // Replace X*(2^C) with X << C
uint64_t C = Log2_64(Val);
return new ShiftInst(Instruction::Shl, Op0,
- ConstantInt::get(Type::UByteTy, C));
+ ConstantInt::get(Type::Int8Ty, C));
}
} else if (ConstantFP *Op1F = dyn_cast<ConstantFP>(Op1)) {
if (Op1F->isNullValue())
@@ -2234,7 +2228,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
if (isa<ConstantInt>(SCIOp1) &&
isSignBitCheck(SCI->getPredicate(), cast<ConstantInt>(SCIOp1))) {
// Shift the X value right to turn it into "all signbits".
- Constant *Amt = ConstantInt::get(Type::UByteTy,
+ Constant *Amt = ConstantInt::get(Type::Int8Ty,
SCOpTy->getPrimitiveSizeInBits()-1);
Value *V =
InsertNewInstBefore(new ShiftInst(Instruction::AShr, SCIOp0, Amt,
@@ -2368,7 +2362,7 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) {
if (isPowerOf2_64(Val)) {
uint64_t ShiftAmt = Log2_64(Val);
return new ShiftInst(Instruction::LShr, Op0,
- ConstantInt::get(Type::UByteTy, ShiftAmt));
+ ConstantInt::get(Type::Int8Ty, ShiftAmt));
}
}
@@ -2400,13 +2394,13 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) {
// Compute the shift amounts
unsigned TSA = Log2_64(TVA), FSA = Log2_64(FVA);
// Construct the "on true" case of the select
- Constant *TC = ConstantInt::get(Type::UByteTy, TSA);
+ Constant *TC = ConstantInt::get(Type::Int8Ty, TSA);
Instruction *TSI =
new ShiftInst(Instruction::LShr, Op0, TC, SI->getName()+".t");
TSI = InsertNewInstBefore(TSI, I);
// Construct the "on false" case of the select
- Constant *FC = ConstantInt::get(Type::UByteTy, FSA);
+ Constant *FC = ConstantInt::get(Type::Int8Ty, FSA);
Instruction *FSI =
new ShiftInst(Instruction::LShr, Op0, FC, SI->getName()+".f");
FSI = InsertNewInstBefore(FSI, I);
@@ -2480,7 +2474,7 @@ static Constant *GetFactor(Value *V) {
unsigned Zeros = CountTrailingZeros_64(RHS->getZExtValue());
if (Zeros != V->getType()->getPrimitiveSizeInBits())
return ConstantExpr::getShl(Result,
- ConstantInt::get(Type::UByteTy, Zeros));
+ ConstantInt::get(Type::Int8Ty, Zeros));
}
} else if (CastInst *CI = dyn_cast<CastInst>(I)) {
// Only handle int->int casts.
@@ -3328,12 +3322,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
Instruction *Add = BinaryOperator::createAdd(LHSVal, AddCST,
LHSVal->getName()+".off");
InsertNewInstBefore(Add, I);
- const Type *UnsType = Add->getType()->getUnsignedVersion();
- Value *OffsetVal = InsertCastBefore(Instruction::BitCast, Add,
- UnsType, I);
- AddCST = ConstantExpr::getSub(RHSCst, LHSCst);
- AddCST = ConstantExpr::getBitCast(AddCST, UnsType);
- return new ICmpInst(ICmpInst::ICMP_UGT, OffsetVal, AddCST);
+ return new ICmpInst(ICmpInst::ICMP_UGT, Add, AddCST);
}
break; // (X != 13 & X != 15) -> no change
}
@@ -3530,7 +3519,7 @@ static bool CollectBSwapParts(Value *V, std::vector<Value*> &ByteValues) {
/// If so, insert the new bswap intrinsic and return it.
Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) {
// We can only handle bswap of unsigned integers, and cannot bswap one byte.
- if (!I.getType()->isUnsigned() || I.getType() == Type::UByteTy)
+ if (I.getType() == Type::Int8Ty)
return 0;
/// ByteValues - For each byte of the result, we keep track of which value
@@ -3556,11 +3545,11 @@ Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) {
// bswap to make it into.
Module *M = I.getParent()->getParent()->getParent();
const char *FnName = 0;
- if (I.getType() == Type::UShortTy)
+ if (I.getType() == Type::Int16Ty)
FnName = "llvm.bswap.i16";
- else if (I.getType() == Type::UIntTy)
+ else if (I.getType() == Type::Int32Ty)
FnName = "llvm.bswap.i32";
- else if (I.getType() == Type::ULongTy)
+ else if (I.getType() == Type::Int64Ty)
FnName = "llvm.bswap.i64";
else
assert(0 && "Unknown integer type!");
@@ -4093,16 +4082,8 @@ static bool AddWithOverflow(ConstantInt *&Result, ConstantInt *In1,
ConstantInt *In2) {
Result = cast<ConstantInt>(ConstantExpr::getAdd(In1, In2));
- if (In1->getType()->isUnsigned())
- return cast<ConstantInt>(Result)->getZExtValue() <
- cast<ConstantInt>(In1)->getZExtValue();
- if (isPositive(In1) != isPositive(In2))
- return false;
- if (isPositive(In1))
- return cast<ConstantInt>(Result)->getSExtValue() <
- cast<ConstantInt>(In1)->getSExtValue();
- return cast<ConstantInt>(Result)->getSExtValue() >
- cast<ConstantInt>(In1)->getSExtValue();
+ return cast<ConstantInt>(Result)->getZExtValue() <
+ cast<ConstantInt>(In1)->getZExtValue();
}
/// EmitGEPOffset - Given a getelementptr instruction/constantexpr, emit the
@@ -4596,17 +4577,10 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
(CI->getZExtValue() == (uint64_t)CI->getSExtValue()))) {
ConstantInt *NewCST;
ConstantInt *NewCI;
- if (Cast->getOperand(0)->getType()->isSigned()) {
- NewCST = ConstantInt::get(Cast->getOperand(0)->getType(),
- AndCST->getZExtValue());
- NewCI = ConstantInt::get(Cast->getOperand(0)->getType(),
- CI->getZExtValue());
- } else {
- NewCST = ConstantInt::get(Cast->getOperand(0)->getType(),
- AndCST->getZExtValue());
- NewCI = ConstantInt::get(Cast->getOperand(0)->getType(),
- CI->getZExtValue());
- }
+ NewCST = ConstantInt::get(Cast->getOperand(0)->getType(),
+ AndCST->getZExtValue());
+ NewCI = ConstantInt::get(Cast->getOperand(0)->getType(),
+ CI->getZExtValue());
Instruction *NewAnd =
BinaryOperator::createAnd(Cast->getOperand(0), NewCST,
LHSI->getName());
@@ -4644,7 +4618,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
int ShAmtVal = Ty->getPrimitiveSizeInBits()-ShAmt->getZExtValue();
if (ShAmtVal < 0) ShAmtVal = 0; // Out of range shift.
- Constant *OShAmt = ConstantInt::get(Type::UByteTy, ShAmtVal);
+ Constant *OShAmt = ConstantInt::get(Type::Int8Ty, ShAmtVal);
Constant *ShVal =
ConstantExpr::getShl(ConstantInt::getAllOnesValue(AndTy),
OShAmt);
@@ -4756,15 +4730,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
// Otherwise strength reduce the shift into an and.
unsigned ShAmtVal = (unsigned)ShAmt->getZExtValue();
uint64_t Val = (1ULL << (TypeBits-ShAmtVal))-1;
-
- Constant *Mask;
- if (CI->getType()->isUnsigned()) {
- Mask = ConstantInt::get(CI->getType(), Val);
- } else if (ShAmtVal != 0) {
- Mask = ConstantInt::get(CI->getType(), Val);
- } else {
- Mask = ConstantInt::getAllOnesValue(CI->getType());
- }
+ Constant *Mask = ConstantInt::get(CI->getType(), Val);
Instruction *AndI =
BinaryOperator::createAnd(LHSI->getOperand(0),
@@ -4791,7 +4757,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
// If we are comparing against bits always shifted out, the
// comparison cannot succeed.
Constant *Comp;
- if (CI->getType()->isUnsigned())
+ if (LHSI->getOpcode() == Instruction::LShr)
Comp = ConstantExpr::getLShr(ConstantExpr::getShl(CI, ShAmt),
ShAmt);
else
@@ -4810,14 +4776,8 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
// Otherwise strength reduce the shift into an and.
uint64_t Val = ~0ULL; // All ones.
Val <<= ShAmtVal; // Shift over to the right spot.
-
- Constant *Mask;
- if (CI->getType()->isUnsigned()) {
- Val &= ~0ULL >> (64-TypeBits);
- Mask = ConstantInt::get(CI->getType(), Val);
- } else {
- Mask = ConstantInt::get(CI->getType(), Val);
- }
+ Val &= ~0ULL >> (64-TypeBits);
+ Constant *Mask = ConstantInt::get(CI->getType(), Val);
Instruction *AndI =
BinaryOperator::createAnd(LHSI->getOperand(0),
@@ -5049,11 +5009,6 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
// Replace (and X, (1 << size(X)-1) != 0) with x s< 0
if (isSignBit(BOC)) {
Value *X = BO->getOperand(0);
- // If 'X' is not signed, insert a cast now...
- if (!BOC->getType()->isSigned()) {
- const Type *DestTy = BOC->getType()->getSignedVersion();
- X = InsertCastBefore(Instruction::BitCast, X, DestTy, I);
- }
Constant *Zero = Constant::getNullValue(X->getType());
ICmpInst::Predicate pred = isICMP_NE ?
ICmpInst::ICMP_SLT : ICmpInst::ICMP_SGE;
@@ -5080,21 +5035,21 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
// icmp eq (bswap(x)), c -> icmp eq (x,bswap(c))
WorkList.push_back(II); // Dead?
I.setOperand(0, II->getOperand(1));
- I.setOperand(1, ConstantInt::get(Type::UShortTy,
+ I.setOperand(1, ConstantInt::get(Type::Int16Ty,
ByteSwap_16(CI->getZExtValue())));
return &I;
case Intrinsic::bswap_i32:
// icmp eq (bswap(x)), c -> icmp eq (x,bswap(c))
WorkList.push_back(II); // Dead?
I.setOperand(0, II->getOperand(1));
- I.setOperand(1, ConstantInt::get(Type::UIntTy,
+ I.setOperand(1, ConstantInt::get(Type::Int32Ty,
ByteSwap_32(CI->getZExtValue())));
return &I;
case Intrinsic::bswap_i64:
// icmp eq (bswap(x)), c -> icmp eq (x,bswap(c))
WorkList.push_back(II); // Dead?
I.setOperand(0, II->getOperand(1));
- I.setOperand(1, ConstantInt::get(Type::ULongTy,
+ I.setOperand(1, ConstantInt::get(Type::Int64Ty,
ByteSwap_64(CI->getZExtValue())));
return &I;
}
@@ -5393,12 +5348,12 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
}
Instruction *InstCombiner::visitShiftInst(ShiftInst &I) {
- assert(I.getOperand(1)->getType() == Type::UByteTy);
+ assert(I.getOperand(1)->getType() == Type::Int8Ty);
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
// shl X, 0 == X and shr X, 0 == X
// shl 0, X == 0 and shr 0, X == 0
- if (Op1 == Constant::getNullValue(Type::UByteTy) ||
+ if (Op1 == Constant::getNullValue(Type::Int8Ty) ||
Op0 == Constant::getNullValue(Op0->getType()))
return ReplaceInstUsesWith(I, Op0);
@@ -5436,9 +5391,8 @@ Instruction *InstCombiner::visitShiftInst(ShiftInst &I) {
}
if (ConstantInt *CUI = dyn_cast<ConstantInt>(Op1))
- if (CUI->getType()->isUnsigned())
- if (Instruction *Res = FoldShiftByConstant(Op0, CUI, I))
- return Res;
+ if (Instruction *Res = FoldShiftByConstant(Op0, CUI, I))
+ return Res;
return 0;
}
@@ -5463,7 +5417,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
if (isUnsignedShift || isLeftShift)
return ReplaceInstUsesWith(I, Constant::getNullValue(Op0->getType()));
else {
- I.setOperand(1, ConstantInt::get(Type::UByteTy, TypeBits-1));
+ I.setOperand(1, ConstantInt::get(Type::Int8Ty, TypeBits-1));
return &I;
}
}
@@ -5657,7 +5611,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
Value *Op = ShiftOp->getOperand(0);
ShiftInst *ShiftResult = new ShiftInst(I.getOpcode(), Op,
- ConstantInt::get(Type::UByteTy, Amt));
+ ConstantInt::get(Type::Int8Ty, Amt));
if (I.getType() == ShiftResult->getType())
return ShiftResult;
InsertNewInstBefore(ShiftResult, I);
@@ -5688,20 +5642,20 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
return ReplaceInstUsesWith(I, Mask); // (A << c) >> c === A & c2
} else if (ShiftAmt1 < ShiftAmt2) {
return new ShiftInst(I.getOpcode(), Mask,
- ConstantInt::get(Type::UByteTy, ShiftAmt2-ShiftAmt1));
+ ConstantInt::get(Type::Int8Ty, ShiftAmt2-ShiftAmt1));
} else if (isShiftOfUnsignedShift || isShiftOfLeftShift) {
if (isShiftOfUnsignedShift && !isShiftOfLeftShift && isSignedShift) {
return new ShiftInst(Instruction::LShr, Mask,
- ConstantInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2));
+ ConstantInt::get(Type::Int8Ty, ShiftAmt1-ShiftAmt2));
} else {
return new ShiftInst(ShiftOp->getOpcode(), Mask,
- ConstantInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2));
+ ConstantInt::get(Type::Int8Ty, ShiftAmt1-ShiftAmt2));
}
} else {
// (X >>s C1) << C2 where C1 > C2 === (X >>s (C1-C2)) & mask
Instruction *Shift =
new ShiftInst(ShiftOp->getOpcode(), Mask,
- ConstantInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2));
+ ConstantInt::get(Type::Int8Ty, ShiftAmt1-ShiftAmt2));
InsertNewInstBefore(Shift, I);
C = ConstantIntegral::getAllOnesValue(Shift->getType());
@@ -5714,9 +5668,9 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
if (ShiftAmt1 == ShiftAmt2) {
const Type *SExtType = 0;
switch (Op0->getType()->getPrimitiveSizeInBits() - ShiftAmt1) {
- case 8 : SExtType = Type::SByteTy; break;
- case 16: SExtType = Type::ShortTy; break;
- case 32: SExtType = Type::IntTy; break;
+ case 8 : SExtType = Type::Int8Ty; break;
+ case 16: SExtType = Type::Int16Ty; break;
+ case 32: SExtType = Type::Int32Ty; break;
}
if (SExtType) {
@@ -5738,38 +5692,34 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
///
static Value *DecomposeSimpleLinearExpr(Value *Val, unsigned &Scale,
unsigned &Offset) {
- assert(Val->getType() == Type::UIntTy && "Unexpected allocation size type!");
+ assert(Val->getType() == Type::Int32Ty && "Unexpected allocation size type!");
if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) {
- if (CI->getType()->isUnsigned()) {
- Offset = CI->getZExtValue();
- Scale = 1;
- return ConstantInt::get(Type::UIntTy, 0);
- }
+ Offset = CI->getZExtValue();
+ Scale = 1;
+ return ConstantInt::get(Type::Int32Ty, 0);
} else if (Instruction *I = dyn_cast<Instruction>(Val)) {
if (I->getNumOperands() == 2) {
if (ConstantInt *CUI = dyn_cast<ConstantInt>(I->getOperand(1))) {
- if (CUI->getType()->isUnsigned()) {
- if (I->getOpcode() == Instruction::Shl) {
- // This is a value scaled by '1 << the shift amt'.
- Scale = 1U << CUI->getZExtValue();
- Offset = 0;
- return I->getOperand(0);
- } else if (I->getOpcode() == Instruction::Mul) {
- // This value is scaled by 'CUI'.
- Scale = CUI->getZExtValue();
- Offset = 0;
- return I->getOperand(0);
- } else if (I->getOpcode() == Instruction::Add) {
- // We have X+C. Check to see if we really have (X*C2)+C1,
- // where C1 is divisible by C2.
- unsigned SubScale;
- Value *SubVal =
- DecomposeSimpleLinearExpr(I->getOperand(0), SubScale, Offset);
- Offset += CUI->getZExtValue();
- if (SubScale > 1 && (Offset % SubScale == 0)) {
- Scale = SubScale;
- return SubVal;
- }
+ if (I->getOpcode() == Instruction::Shl) {
+ // This is a value scaled by '1 << the shift amt'.
+ Scale = 1U << CUI->getZExtValue();
+ Offset = 0;
+ return I->getOperand(0);
+ } else if (I->getOpcode() == Instruction::Mul) {
+ // This value is scaled by 'CUI'.
+ Scale = CUI->getZExtValue();
+ Offset = 0;
+ return I->getOperand(0);
+ } else if (I->getOpcode() == Instruction::Add) {
+ // We have X+C. Check to see if we really have (X*C2)+C1,
+ // where C1 is divisible by C2.
+ unsigned SubScale;
+ Value *SubVal =
+ DecomposeSimpleLinearExpr(I->getOperand(0), SubScale, Offset);
+ Offset += CUI->getZExtValue();
+ if (SubScale > 1 && (Offset % SubScale == 0)) {
+ Scale = SubScale;
+ return SubVal;
}
}
}
@@ -5844,8 +5794,8 @@ Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI,
Amt = NumElements;
} else {
// If the allocation size is constant, form a constant mul expression
- Amt = ConstantInt::get(Type::UIntTy, Scale);
- if (isa<ConstantInt>(NumElements) && NumElements->getType()->isUnsigned())
+ Amt = ConstantInt::get(Type::Int32Ty, Scale);
+ if (isa<ConstantInt>(NumElements))
Amt = ConstantExpr::getMul(
cast<ConstantInt>(NumElements), cast<ConstantInt>(Amt));
// otherwise multiply the amount and the number of elements
@@ -5856,7 +5806,7 @@ Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI,
}
if (unsigned Offset = (AllocElTySize*ArrayOffset)/CastElTySize) {
- Value *Off = ConstantInt::get(Type::UIntTy, Offset);
+ Value *Off = ConstantInt::get(Type::Int32Ty, Offset);
Instruction *Tmp = BinaryOperator::createAdd(Amt, Off, "tmp");
Amt = InsertNewInstBefore(Tmp, AI);
}
@@ -6117,7 +6067,7 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) {
// We need to emit an AND to clear the high bits.
assert(SrcBitSize < DestBitSize && "Not a zext?");
Constant *C =
- ConstantInt::get(Type::ULongTy, (1ULL << SrcBitSize)-1);
+ ConstantInt::get(Type::Int64Ty, (1ULL << SrcBitSize)-1);
if (DestBitSize < 64)
C = ConstantExpr::getTrunc(C, DestTy);
else {
@@ -6261,7 +6211,7 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) {
// Insert the shift to put the result in the low bit.
In = InsertNewInstBefore(
new ShiftInst(Instruction::LShr, In,
- ConstantInt::get(Type::UByteTy, ShiftAmt),
+ ConstantInt::get(Type::Int8Ty, ShiftAmt),
In->getName()+".lobit"), CI);
}
@@ -6442,7 +6392,7 @@ Instruction *InstCombiner::visitBitCast(CastInst &CI) {
const Type *DstElTy = DstPTy->getElementType();
const Type *SrcElTy = SrcPTy->getElementType();
- Constant *ZeroUInt = Constant::getNullValue(Type::UIntTy);
+ Constant *ZeroUInt = Constant::getNullValue(Type::Int32Ty);
unsigned NumZeros = 0;
while (SrcElTy != DstElTy &&
isa<CompositeType>(SrcElTy) && !isa<PointerType>(SrcElTy) &&
@@ -6530,7 +6480,7 @@ static Constant *GetSelectFoldableConstant(Instruction *I) {
case Instruction::Shl:
case Instruction::LShr:
case Instruction::AShr:
- return Constant::getNullValue(Type::UByteTy);
+ return Constant::getNullValue(Type::Int8Ty);
case Instruction::And:
return ConstantInt::getAllOnesValue(I->getType());
case Instruction::Mul:
@@ -6697,7 +6647,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
// same width. Make an all-ones value by inserting a AShr.
Value *X = IC->getOperand(0);
unsigned Bits = X->getType()->getPrimitiveSizeInBits();
- Constant *ShAmt = ConstantInt::get(Type::UByteTy, Bits-1);
+ Constant *ShAmt = ConstantInt::get(Type::Int8Ty, Bits-1);
Instruction *SRA = new ShiftInst(Instruction::AShr, X,
ShAmt, "ones");
InsertNewInstBefore(SRA, SI);
@@ -6927,7 +6877,7 @@ static unsigned GetKnownAlignment(Value *V, TargetData *TD) {
// Malloc returns maximally aligned memory.
Align = TD->getTypeAlignment(AI->getType()->getElementType());
Align = std::max(Align, (unsigned)TD->getTypeAlignment(Type::DoubleTy));
- Align = std::max(Align, (unsigned)TD->getTypeAlignment(Type::LongTy));
+ Align = std::max(Align, (unsigned)TD->getTypeAlignment(Type::Int64Ty));
}
}
return Align;
@@ -7007,7 +6957,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
Module *M = CI.getParent()->getParent()->getParent();
const char *Name;
if (CI.getCalledFunction()->getFunctionType()->getParamType(2) ==
- Type::UIntTy)
+ Type::Int32Ty)
Name = "llvm.memcpy.i32";
else
Name = "llvm.memcpy.i64";
@@ -7025,13 +6975,13 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
unsigned Alignment2 = GetKnownAlignment(MI->getOperand(2), TD);
unsigned Align = std::min(Alignment1, Alignment2);
if (MI->getAlignment()->getZExtValue() < Align) {
- MI->setAlignment(ConstantInt::get(Type::UIntTy, Align));
+ MI->setAlignment(ConstantInt::get(Type::Int32Ty, Align));
Changed = true;
}
} else if (isa<MemSetInst>(MI)) {
unsigned Alignment = GetKnownAlignment(MI->getDest(), TD);
if (MI->getAlignment()->getZExtValue() < Alignment) {
- MI->setAlignment(ConstantInt::get(Type::UIntTy, Alignment));
+ MI->setAlignment(ConstantInt::get(Type::Int32Ty, Alignment));
Changed = true;
}
}
@@ -7298,7 +7248,6 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
//Either we can cast directly, or we can upconvert the argument
bool isConvertible = ActTy->canLosslesslyBitCastTo(ParamTy) ||
(ParamTy->isIntegral() && ActTy->isIntegral() &&
- ParamTy->isSigned() == ActTy->isSigned() &&
ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize()) ||
(c && ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize() &&
c->getSExtValue() > 0);
@@ -7321,7 +7270,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
Args.push_back(*AI);
} else {
Instruction::CastOps opcode = CastInst::getCastOpcode(*AI,
- (*AI)->getType()->isSigned(), ParamTy, ParamTy->isSigned());
+ false, ParamTy, false);
CastInst *NewCast = CastInst::create(opcode, *AI, ParamTy, "tmp");
Args.push_back(InsertNewInstBefore(NewCast, *Caller));
}
@@ -7343,8 +7292,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
const Type *PTy = getPromotedType((*AI)->getType());
if (PTy != (*AI)->getType()) {
// Must promote to pass through va_arg area!
- Instruction::CastOps opcode = CastInst::getCastOpcode(
- *AI, (*AI)->getType()->isSigned(), PTy, PTy->isSigned());
+ Instruction::CastOps opcode = CastInst::getCastOpcode(*AI, false,
+ PTy, false);
Instruction *Cast = CastInst::create(opcode, *AI, PTy, "tmp");
InsertNewInstBefore(Cast, *Caller);
Args.push_back(Cast);
@@ -7374,8 +7323,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
if (Caller->getType() != NV->getType() && !Caller->use_empty()) {
if (NV->getType() != Type::VoidTy) {
const Type *CallerTy = Caller->getType();
- Instruction::CastOps opcode = CastInst::getCastOpcode(
- NC, NC->getType()->isSigned(), CallerTy, CallerTy->isSigned());
+ Instruction::CastOps opcode = CastInst::getCastOpcode(NC, false,
+ CallerTy, false);
NV = NC = CastInst::create(opcode, NC, CallerTy, "tmp");
// If this is an invoke instruction, we should insert it after the first
@@ -7728,14 +7677,6 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
GEP.setOperand(i, Op);
MadeChange = true;
}
- // If this is a constant idx, make sure to canonicalize it to be a signed
- // operand, otherwise CSE and other optimizations are pessimized.
- if (ConstantInt *CUI = dyn_cast<ConstantInt>(Op))
- if (CUI->getType()->isUnsigned()) {
- GEP.setOperand(i,
- ConstantExpr::getBitCast(CUI, CUI->getType()->getSignedVersion()));
- MadeChange = true;
- }
}
if (MadeChange) return &GEP;
@@ -7878,7 +7819,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
TD->getTypeSize(cast<ArrayType>(SrcElTy)->getElementType()) ==
TD->getTypeSize(ResElTy)) {
Value *V = InsertNewInstBefore(
- new GetElementPtrInst(X, Constant::getNullValue(Type::IntTy),
+ new GetElementPtrInst(X, Constant::getNullValue(Type::Int32Ty),
GEP.getOperand(1), GEP.getName()), GEP);
// V and GEP are both pointer types --> BitCast
return new BitCastInst(V, GEP.getType());
@@ -7890,7 +7831,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
// getelementptr [100 x double]* %arr, int 0, int %tmp.2
if (isa<ArrayType>(SrcElTy) &&
- (ResElTy == Type::SByteTy || ResElTy == Type::UByteTy)) {
+ (ResElTy == Type::Int8Ty || ResElTy == Type::Int8Ty)) {
uint64_t ArrayEltSize =
TD->getTypeSize(cast<ArrayType>(SrcElTy)->getElementType());
@@ -7933,7 +7874,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
// Insert the new GEP instruction.
Instruction *NewGEP =
- new GetElementPtrInst(X, Constant::getNullValue(Type::IntTy),
+ new GetElementPtrInst(X, Constant::getNullValue(Type::Int32Ty),
NewIdx, GEP.getName());
NewGEP = InsertNewInstBefore(NewGEP, GEP);
// The NewGEP must be pointer typed, so must the old one -> BitCast
@@ -7973,7 +7914,7 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) {
// Now that I is pointing to the first non-allocation-inst in the block,
// insert our getelementptr instruction...
//
- Value *NullIdx = Constant::getNullValue(Type::IntTy);
+ Value *NullIdx = Constant::getNullValue(Type::Int32Ty);
Value *V = new GetElementPtrInst(New, NullIdx, NullIdx,
New->getName()+".sub", It);
@@ -8038,7 +7979,7 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI) {
if (const ArrayType *ASrcTy = dyn_cast<ArrayType>(SrcPTy))
if (Constant *CSrc = dyn_cast<Constant>(CastOp))
if (ASrcTy->getNumElements() != 0) {
- std::vector<Value*> Idxs(2, Constant::getNullValue(Type::IntTy));
+ std::vector<Value*> Idxs(2, Constant::getNullValue(Type::Int32Ty));
CastOp = ConstantExpr::getGetElementPtr(CSrc, Idxs);
SrcTy = cast<PointerType>(CastOp->getType());
SrcPTy = SrcTy->getElementType();
@@ -8225,7 +8166,7 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) {
if (const ArrayType *ASrcTy = dyn_cast<ArrayType>(SrcPTy))
if (Constant *CSrc = dyn_cast<Constant>(CastOp))
if (ASrcTy->getNumElements() != 0) {
- std::vector<Value*> Idxs(2, Constant::getNullValue(Type::IntTy));
+ std::vector<Value*> Idxs(2, Constant::getNullValue(Type::Int32Ty));
CastOp = ConstantExpr::getGetElementPtr(CSrc, Idxs);
SrcTy = cast<PointerType>(CastOp->getType());
SrcPTy = SrcTy->getElementType();
@@ -8696,15 +8637,15 @@ static bool CollectSingleShuffleElements(Value *V, Value *LHS, Value *RHS,
unsigned NumElts = cast<PackedType>(V->getType())->getNumElements();
if (isa<UndefValue>(V)) {
- Mask.assign(NumElts, UndefValue::get(Type::UIntTy));
+ Mask.assign(NumElts, UndefValue::get(Type::Int32Ty));
return true;
} else if (V == LHS) {
for (unsigned i = 0; i != NumElts; ++i)
- Mask.push_back(ConstantInt::get(Type::UIntTy, i));
+ Mask.push_back(ConstantInt::get(Type::Int32Ty, i));
return true;
} else if (V == RHS) {
for (unsigned i = 0; i != NumElts; ++i)
- Mask.push_back(ConstantInt::get(Type::UIntTy, i+NumElts));
+ Mask.push_back(ConstantInt::get(Type::Int32Ty, i+NumElts));
return true;
} else if (InsertElementInst *IEI = dyn_cast<InsertElementInst>(V)) {
// If this is an insert of an extract from some other vector, include it.
@@ -8721,7 +8662,7 @@ static bool CollectSingleShuffleElements(Value *V, Value *LHS, Value *RHS,
// transitively ok.
if (CollectSingleShuffleElements(VecOp, LHS, RHS, Mask)) {
// If so, update the mask to reflect the inserted undef.
- Mask[InsertedIdx] = UndefValue::get(Type::UIntTy);
+ Mask[InsertedIdx] = UndefValue::get(Type::Int32Ty);
return true;
}
} else if (ExtractElementInst *EI = dyn_cast<ExtractElementInst>(ScalarOp)){
@@ -8738,11 +8679,11 @@ static bool CollectSingleShuffleElements(Value *V, Value *LHS, Value *RHS,
// If so, update the mask to reflect the inserted value.
if (EI->getOperand(0) == LHS) {
Mask[InsertedIdx & (NumElts-1)] =
- ConstantInt::get(Type::UIntTy, ExtractedIdx);
+ ConstantInt::get(Type::Int32Ty, ExtractedIdx);
} else {
assert(EI->getOperand(0) == RHS);
Mask[InsertedIdx & (NumElts-1)] =
- ConstantInt::get(Type::UIntTy, ExtractedIdx+NumElts);
+ ConstantInt::get(Type::Int32Ty, ExtractedIdx+NumElts);
}
return true;
@@ -8767,10 +8708,10 @@ static Value *CollectShuffleElements(Value *V, std::vector<Constant*> &Mask,
unsigned NumElts = cast<PackedType>(V->getType())->getNumElements();
if (isa<UndefValue>(V)) {
- Mask.assign(NumElts, UndefValue::get(Type::UIntTy));
+ Mask.assign(NumElts, UndefValue::get(Type::Int32Ty));
return V;
} else if (isa<ConstantAggregateZero>(V)) {
- Mask.assign(NumElts, ConstantInt::get(Type::UIntTy, 0));
+ Mask.assign(NumElts, ConstantInt::get(Type::Int32Ty, 0));
return V;
} else if (InsertElementInst *IEI = dyn_cast<InsertElementInst>(V)) {
// If this is an insert of an extract from some other vector, include it.
@@ -8791,7 +8732,7 @@ static Value *CollectShuffleElements(Value *V, std::vector<Constant*> &Mask,
RHS = EI->getOperand(0);
Value *V = CollectShuffleElements(VecOp, Mask, RHS);
Mask[InsertedIdx & (NumElts-1)] =
- ConstantInt::get(Type::UIntTy, NumElts+ExtractedIdx);
+ ConstantInt::get(Type::Int32Ty, NumElts+ExtractedIdx);
return V;
}
@@ -8800,7 +8741,7 @@ static Value *CollectShuffleElements(Value *V, std::vector<Constant*> &Mask,
// Everything but the extracted element is replaced with the RHS.
for (unsigned i = 0; i != NumElts; ++i) {
if (i != InsertedIdx)
- Mask[i] = ConstantInt::get(Type::UIntTy, NumElts+i);
+ Mask[i] = ConstantInt::get(Type::Int32Ty, NumElts+i);
}
return V;
}
@@ -8817,7 +8758,7 @@ static Value *CollectShuffleElements(Value *V, std::vector<Constant*> &Mask,
// Otherwise, can't do anything fancy. Return an identity vector.
for (unsigned i = 0; i != NumElts; ++i)
- Mask.push_back(ConstantInt::get(Type::UIntTy, i));
+ Mask.push_back(ConstantInt::get(Type::Int32Ty, i));
return V;
}
@@ -8856,13 +8797,13 @@ Instruction *InstCombiner::visitInsertElementInst(InsertElementInst &IE) {
// Build a new shuffle mask.
std::vector<Constant*> Mask;
if (isa<UndefValue>(VecOp))
- Mask.assign(NumVectorElts, UndefValue::get(Type::UIntTy));
+ Mask.assign(NumVectorElts, UndefValue::get(Type::Int32Ty));
else {
assert(isa<ConstantAggregateZero>(VecOp) && "Unknown thing");
- Mask.assign(NumVectorElts, ConstantInt::get(Type::UIntTy,
+ Mask.assign(NumVectorElts, ConstantInt::get(Type::Int32Ty,
NumVectorElts));
}
- Mask[InsertedIdx] = ConstantInt::get(Type::UIntTy, ExtractedIdx);
+ Mask[InsertedIdx] = ConstantInt::get(Type::Int32Ty, ExtractedIdx);
return new ShuffleVectorInst(EI->getOperand(0), VecOp,
ConstantPacked::get(Mask));
}
@@ -8910,14 +8851,14 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
std::vector<Constant*> Elts;
for (unsigned i = 0, e = Mask.size(); i != e; ++i) {
if (Mask[i] >= 2*e)
- Elts.push_back(UndefValue::get(Type::UIntTy));
+ Elts.push_back(UndefValue::get(Type::Int32Ty));
else {
if ((Mask[i] >= e && isa<UndefValue>(RHS)) ||
(Mask[i] < e && isa<UndefValue>(LHS)))
Mask[i] = 2*e; // Turn into undef.
else
Mask[i] &= (e-1); // Force to LHS.
- Elts.push_back(ConstantInt::get(Type::UIntTy, Mask[i]));
+ Elts.push_back(ConstantInt::get(Type::Int32Ty, Mask[i]));
}
}
SVI.setOperand(0, SVI.getOperand(1));
@@ -8970,9 +8911,9 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
std::vector<Constant*> Elts;
for (unsigned i = 0, e = NewMask.size(); i != e; ++i) {
if (NewMask[i] >= e*2) {
- Elts.push_back(UndefValue::get(Type::UIntTy));
+ Elts.push_back(UndefValue::get(Type::Int32Ty));
} else {
- Elts.push_back(ConstantInt::get(Type::UIntTy, NewMask[i]));
+ Elts.push_back(ConstantInt::get(Type::Int32Ty, NewMask[i]));
}
}
return new ShuffleVectorInst(LHSSVI->getOperand(0),
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 1908693cc2..3e92a16882 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -86,8 +86,8 @@ namespace {
Value *IncV;
IVExpr()
- : Stride(SCEVUnknown::getIntegerSCEV(0, Type::UIntTy)),
- Base (SCEVUnknown::getIntegerSCEV(0, Type::UIntTy)) {}
+ : Stride(SCEVUnknown::getIntegerSCEV(0, Type::Int32Ty)),
+ Base (SCEVUnknown::getIntegerSCEV(0, Type::Int32Ty)) {}
IVExpr(const SCEVHandle &stride, const SCEVHandle &base, PHINode *phi,
Value *incv)
: Stride(stride), Base(base), PHI(phi), IncV(incv) {}
@@ -334,12 +334,6 @@ static bool getSCEVStartAndStride(const SCEVHandle &SH, Loop *L,
<< "] Variable stride: " << *AddRec << "\n";
Stride = AddRec->getOperand(1);
- // Check that all constant strides are the unsigned type, we don't want to
- // have two IV's one of signed stride 4 and one of unsigned stride 4 to not be
- // merged.
- assert((!isa<SCEVConstant>(Stride) || Stride->getType()->isUnsigned()) &&
- "Constants should be canonicalized to unsigned!");
-
return true;
}
@@ -899,7 +893,7 @@ unsigned LoopStrengthReduce::CheckForIVReuse(const SCEVHandle &Stride,
if (unsigned(abs(SInt)) < Scale || (SInt % Scale) != 0)
continue;
std::map<SCEVHandle, IVsOfOneStride>::iterator SI =
- IVsByStride.find(SCEVUnknown::getIntegerSCEV(SInt/Scale, Type::UIntTy));
+ IVsByStride.find(SCEVUnknown::getIntegerSCEV(SInt/Scale, Type::Int32Ty));
if (SI == IVsByStride.end())
continue;
for (std::vector<IVExpr>::iterator II = SI->second.IVs.begin(),
diff --git a/lib/Transforms/Scalar/LowerGC.cpp b/lib/Transforms/Scalar/LowerGC.cpp
index e844213b6a..e0d6933821 100644
--- a/lib/Transforms/Scalar/LowerGC.cpp
+++ b/lib/Transforms/Scalar/LowerGC.cpp
@@ -83,7 +83,7 @@ const StructType *LowerGC::getRootRecordType(unsigned NumRoots) {
MainRootRecordType ? (Type*)MainRootRecordType : (Type*)OpaqueType::get();
ST.clear();
ST.push_back(PointerType::get(RootListH)); // Prev pointer
- ST.push_back(Type::UIntTy); // NumElements in array
+ ST.push_back(Type::Int32Ty); // NumElements in array
ST.push_back(PairArrTy); // The pairs
StructType *RootList = StructType::get(ST);
if (MainRootRecordType)
@@ -103,7 +103,7 @@ bool LowerGC::doInitialization(Module &M) {
GCWriteInt = M.getNamedFunction("llvm.gcwrite");
if (!GCRootInt && !GCReadInt && !GCWriteInt) return false;
- PointerType *VoidPtr = PointerType::get(Type::SByteTy);
+ PointerType *VoidPtr = PointerType::get(Type::Int8Ty);
PointerType *VoidPtrPtr = PointerType::get(VoidPtr);
// If the program is using read/write barriers, find the implementations of
@@ -159,7 +159,7 @@ bool LowerGC::runOnFunction(Function &F) {
// Quick exit for programs that are not using GC mechanisms.
if (!GCRootInt && !GCReadInt && !GCWriteInt) return false;
- PointerType *VoidPtr = PointerType::get(Type::SByteTy);
+ PointerType *VoidPtr = PointerType::get(Type::Int8Ty);
PointerType *VoidPtrPtr = PointerType::get(VoidPtr);
// If there are read/write barriers in the program, perform a quick pass over
@@ -225,8 +225,8 @@ bool LowerGC::runOnFunction(Function &F) {
BasicBlock::iterator IP = AI;
while (isa<AllocaInst>(IP)) ++IP;
- Constant *Zero = ConstantInt::get(Type::UIntTy, 0);
- Constant *One = ConstantInt::get(Type::UIntTy, 1);
+ Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
+ Constant *One = ConstantInt::get(Type::Int32Ty, 1);
// Get a pointer to the prev pointer.
std::vector<Value*> Par;
@@ -240,11 +240,11 @@ bool LowerGC::runOnFunction(Function &F) {
new StoreInst(PrevPtr, PrevPtrPtr, IP);
// Set the number of elements in this record.
- Par[1] = ConstantInt::get(Type::UIntTy, 1);
+ Par[1] = ConstantInt::get(Type::Int32Ty, 1);
Value *NumEltsPtr = new GetElementPtrInst(AI, Par, "numeltsptr", IP);
- new StoreInst(ConstantInt::get(Type::UIntTy, GCRoots.size()), NumEltsPtr,IP);
+ new StoreInst(ConstantInt::get(Type::Int32Ty, GCRoots.size()), NumEltsPtr,IP);
- Par[1] = ConstantInt::get(Type::UIntTy, 2);
+ Par[1] = ConstantInt::get(Type::Int32Ty, 2);
Par.resize(4);
const PointerType *PtrLocTy =
@@ -254,7 +254,7 @@ bool LowerGC::runOnFunction(Function &F) {
// Initialize all of the gcroot records now, and eliminate them as we go.
for (unsigned i = 0, e = GCRoots.size(); i != e; ++i) {
// Initialize the meta-data pointer.
- Par[2] = ConstantInt::get(Type::UIntTy, i);
+ Par[2] = ConstantInt::get(Type::Int32Ty, i);
Par[3] = One;
Value *MetaDataPtr = new GetElementPtrInst(AI, Par, "MetaDataPtr", IP);
assert(isa<Constant>(GCRoots[i]->getOperand(2)) && "Must be a constant");
diff --git a/lib/Transforms/Scalar/LowerPacked.cpp b/lib/Transforms/Scalar/LowerPacked.cpp
index 7763921d18..c2ec981c19 100644
--- a/lib/Transforms/Scalar/LowerPacked.cpp
+++ b/lib/Transforms/Scalar/LowerPacked.cpp
@@ -209,7 +209,7 @@ void LowerPacked::visitLoadInst(LoadInst& LI)
if (const PackedType* PKT = dyn_cast<PackedType>(LI.getType())) {
// Initialization, Idx is needed for getelementptr needed later
std::vector<Value*> Idx(2);
- Idx[0] = ConstantInt::get(Type::UIntTy,0);
+ Idx[0] = ConstantInt::get(Type::Int32Ty,0);
ArrayType* AT = ArrayType::get(PKT->getContainedType(0),
PKT->getNumElements());
@@ -225,7 +225,7 @@ void LowerPacked::visitLoadInst(LoadInst& LI)
for (unsigned i = 0, e = PKT->getNumElements(); i != e; ++i) {
// Calculate the second index we will need
- Idx[1] = ConstantInt::get(Type::UIntTy,i);
+ Idx[1] = ConstantInt::get(Type::Int32Ty,i);
// Get the pointer
Value* val = new GetElementPtrInst(array,
@@ -308,7 +308,7 @@ void LowerPacked::visitStoreInst(StoreInst& SI)
dyn_cast<PackedType>(SI.getOperand(0)->getType())) {
// We will need this for getelementptr
std::vector<Value*> Idx(2);
- Idx[0] = ConstantInt::get(Type::UIntTy,0);
+ Idx[0] = ConstantInt::get(Type::Int32Ty,0);
ArrayType* AT = ArrayType::get(PKT->getContainedType(0),
PKT->getNumElements());
@@ -325,7 +325,7 @@ void LowerPacked::visitStoreInst(StoreInst& SI)
for (unsigned i = 0, e = PKT->getNumElements(); i != e; ++i) {
// Generate the indices for getelementptr
- Idx[1] = ConstantInt::get(Type::UIntTy,i);
+ Idx[1] = ConstantInt::get(Type::Int32Ty,i);
Value* val = new GetElementPtrInst(array,
Idx,
"store.ge." +
@@ -375,12 +375,12 @@ void LowerPacked::visitExtractElementInst(ExtractElementInst& EI)
} else {
AllocaInst *alloca =
new AllocaInst(PTy->getElementType(),
- ConstantInt::get(Type::UIntTy, PTy->getNumElements()),
+ ConstantInt::get(Type::Int32Ty, PTy->getNumElements()),
EI.getName() + ".alloca",
EI.getParent()->getParent()->getEntryBlock().begin());
for (unsigned i = 0; i < PTy->getNumElements(); ++i) {
GetElementPtrInst *GEP =
- new GetElementPtrInst(alloca, ConstantInt::get(Type::UIntTy, i),
+ new GetElementPtrInst(alloca, ConstantInt::get(Type::Int32Ty, i),
"store.ge", &EI);
new StoreInst(op0Vals[i], GEP, &EI);
}
@@ -411,7 +411,7 @@ void LowerPacked::visitInsertElementInst(InsertElementInst& IE)
for (unsigned i = 0; i != Vals.size(); ++i) {
ICmpInst *icmp =
new ICmpInst(ICmpInst::ICMP_EQ, Idx,
- ConstantInt::get(Type::UIntTy, i),
+ ConstantInt::get(Type::Int32Ty, i),
"icmp", &IE);
SelectInst *select =
new SelectInst(icmp, Elt, Vals[i], "select", &IE);
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index 695d4c3169..b8d191a009 100644
--- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -226,7 +226,7 @@ bool SROA::performScalarRepl(Function &F) {
//
std::string OldName = GEPI->getName(); // Steal the old name.
std::vector<Value*> NewArgs;
- NewArgs.push_back(Constant::getNullValue(Type::IntTy));
+ NewArgs.push_back(Constant::getNullValue(Type::Int32Ty));
NewArgs.insert(NewArgs.end(), GEPI->op_begin()+3, GEPI->op_end());
GEPI->setName("");
RepValue = new GetElementPtrInst(AllocaToUse, NewArgs, OldName, GEPI);
@@ -389,7 +389,7 @@ void SROA::CanonicalizeAllocaUsers(AllocationInst *AI) {
if (!isa<ConstantInt>(I.getOperand())) {
if (NumElements == 1) {
- GEPI->setOperand(2, Constant::getNullValue(Type::IntTy));
+ GEPI->setOperand(2, Constant::getNullValue(Type::Int32Ty));
} else {
assert(NumElements == 2 && "Unhandled case!");
// All users of the GEP must be loads. At each use of the GEP, insert
@@ -399,10 +399,10 @@ void SROA::CanonicalizeAllocaUsers(AllocationInst *AI) {
"isone", GEPI);
// Insert the new GEP instructions, which are properly indexed.
std::vector<Value*> Indices(GEPI->op_begin()+1, GEPI->op_end());
- Indices[1] = Constant::getNullValue(Type::IntTy);
+ Indices[1] = Constant::getNullValue(Type::Int32Ty);
Value *ZeroIdx = new GetElementPtrInst(GEPI->getOperand(0), Indices,
GEPI->getName()+".0", GEPI);
- Indices[1] = ConstantInt::get(Type::IntTy, 1);
+ Indices[1] = ConstantInt::get(Type::Int32Ty, 1);
Value *OneIdx = new GetElementPtrInst(GEPI->getOperand(0), Indices,
GEPI->getName()+".1", GEPI);
// Replace all loads of the variable index GEP with loads from both
@@ -468,8 +468,8 @@ static bool MergeInType(const Type *In, const Type *&Accum,
// Pointer/FP/Integer unions merge together as integers.
switch (Accum->getTypeID()) {
case Type::PointerTyID: Accum = TD.getIntPtrType(); break;
- case Type::FloatTyID: Accum = Type::UIntTy; break;
- case Type::DoubleTyID: Accum = Type::ULongTy; break;
+ case Type::FloatTyID: Accum = Type::Int32Ty; break;
+ case Type::DoubleTyID: Accum = Type::Int64Ty; break;
default:
assert(Accum->isIntegral() && "Unknown FP type!");
break;
@@ -477,8 +477,8 @@ static bool MergeInType(const Type *In, const Type *&Accum,
switch (In->getTypeID()) {
case Type::PointerTyID: In = TD.getIntPtrType(); break;
- case Type::FloatTyID: In = Type::UIntTy; break;
- case Type::DoubleTyID: In = Type::ULongTy; break;
+ case Type::FloatTyID: In = Type::Int32Ty; break;
+ case Type::DoubleTyID: In = Type::Int64Ty; break;
default:
assert(In->isIntegral() && "Unknown FP type!");
break;
@@ -493,10 +493,10 @@ static bool MergeInType(const Type *In, const Type *&Accum,
/// null.
const Type *getUIntAtLeastAsBitAs(unsigned NumBits) {
if (NumBits > 64) return 0;
- if (NumBits > 32) return Type::ULongTy;
- if (NumBits > 16) return Type::UIntTy;
- if (NumBits > 8) return Type::UShortTy;
- return Type::UByteTy;
+ if (NumBits > 32) return Type::Int64Ty;
+ if (NumBits > 16) return Type::Int32Ty;
+ if (NumBits > 8) return Type::Int16Ty;
+ return Type::Int8Ty;
}
/// CanConvertToScalar - V is a pointer. If we can convert the pointee to a
@@ -610,9 +610,6 @@ void SROA::ConvertToScalar(AllocationInst *AI, const Type *ActualTy) {
"Not in the entry block!");
EntryBlock->getInstList().remove(AI); // Take the alloca out of the program.
- if (ActualTy->isInteger())
- ActualTy = ActualTy->getUnsignedVersion();
-
// Create and insert the alloca.
AllocaInst *NewAI = new AllocaInst(ActualTy, 0, AI->getName(),
EntryBlock->begin());
@@ -646,7 +643,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) {
} else {
// Must be an element access.
unsigned Elt = Offset/(TD.getTypeSize(PTy->getElementType())*8);
- NV = new ExtractElementInst(NV, ConstantInt::get(Type::UIntTy, Elt),
+ NV = new ExtractElementInst(NV, ConstantInt::get(Type::Int32Ty, Elt),
"tmp", LI);
}
} else if (isa<PointerType>(NV->getType())) {
@@ -658,7 +655,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) {
assert(NV->getType()->isInteger() && "Unknown promotion!");
if (Offset && Offset < TD.getTypeSize(NV->getType())*8) {
NV = new ShiftInst(Instruction::LShr, NV,
- ConstantInt::get(Type::UByteTy, Offset),
+ ConstantInt::get(Type::Int8Ty, Offset),
LI->getName(), LI);
}
@@ -673,10 +670,10 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) {
switch (LI->getType()->getTypeID()) {
default: assert(0 && "Unknown FP type!");
case Type::FloatTyID:
- NV = new TruncInst(NV, Type::UIntTy, LI->getName(), LI);
+ NV = new TruncInst(NV, Type::Int32Ty, LI->getName(), LI);
break;
case Type::DoubleTyID:
- NV = new TruncInst(NV, Type::ULongTy, LI->getName(), LI);
+ NV = new TruncInst(NV, Type::Int64Ty, LI->getName(), LI);
break;
}
}
@@ -710,7 +707,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) {
// Must be an element insertion.
unsigned Elt = Offset/(TD.getTypeSize(PTy->getElementType())*8);
SV = new InsertElementInst(Old, SV,
- ConstantInt::get(Type::UIntTy, Elt),
+ ConstantInt::get(Type::Int32Ty, Elt),
"tmp", SI);
}
} else {
@@ -722,10 +719,10 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) {
assert(!SV->getType()->isFloatingPoint() && "Unknown FP type!");
break;
case Type::FloatTyID:
- SV = new BitCastInst(SV, Type::UIntTy, SV->getName(), SI);
+ SV = new BitCastInst(SV, Type::Int32Ty, SV->getName(), SI);
break;
case Type::DoubleTyID:
- SV = new BitCastInst(SV, Type::ULongTy, SV->getName(), SI);
+ SV = new BitCastInst(SV, Type::Int64Ty, SV->getName(), SI);
break;
case Type::PointerTyID:
if (isa<PointerType>(AllocaType))
@@ -743,7 +740,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) {
SV->getName(), SI);
if (Offset && Offset < AllocaType->getPrimitiveSizeInBits())
SV = new ShiftInst(Instruction::Shl, SV,
- ConstantInt::get(Type::UByteTy, Offset),
+ ConstantInt::get(Type::Int8Ty, Offset),
SV->getName()+".adj", SI);
// Mask out the bits we are about to insert from the old value.
unsigned TotalBits = TD.getTypeSize(SV->getType())*8;
diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp
index b6739f40b2..a4b3609942 100644
--- a/lib/Transforms/TransformInternals.cpp
+++ b/lib/Transforms/TransformInternals.cpp
@@ -34,7 +34,7 @@ static const Type *getStructOffsetStep(const StructType *STy, uint64_t &Offset,
(i == SL->MemberOffsets.size()-1 || Offset < SL->MemberOffsets[i+1]));
// Make sure to save the current index...
- Indices.push_back(ConstantInt::get(Type::UIntTy, i));
+ Indices.push_back(ConstantInt::get(Type::Int32Ty, i));
Offset = SL->MemberOffsets[i];
return STy->getContainedType(i);
}
@@ -73,11 +73,11 @@ const Type *llvm::getStructOffsetType(const Type *Ty, unsigned &Offset,
NextType = ATy->getElementType();
unsigned ChildSize = (unsigned)TD.getTypeSize(NextType);
- if (ConstantInt::isValueValidForType(Type::IntTy,
+ if (ConstantInt::isValueValidForType(Type::Int32Ty,
uint64_t(Offset/ChildSize)))
- Indices.push_back(ConstantInt::get(Type::IntTy, Offset/ChildSize));
+ Indices.push_back(ConstantInt::get(Type::Int32Ty, Offset/ChildSize));
else
- Indices.push_back(ConstantInt::get(Type::LongTy, Offset/ChildSize));
+ Indices.push_back(ConstantInt::get(Type::Int64Ty, Offset/ChildSize));
ThisOffset = (Offset/ChildSize)*ChildSize;
} else {
Offset = 0; // Return the offset that we were able to achieve
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp
index a63e4e0407..ebf1ac63c6 100644
--- a/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/lib/Transforms/Utils/CodeExtractor.cpp
@@ -252,7 +252,7 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
case 0:
case 1: RetTy = Type::VoidTy; break;
case 2: RetTy = Type::BoolTy; break;
- default: RetTy = Type::UShortTy; break;
+ default: RetTy = Type::Int16Ty; break;
}
std::vector<const Type*> paramTy;
@@ -304,8 +304,8 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
Value *RewriteVal;
if (AggregateArgs) {
std::vector<Value*> Indices;
- Indices.push_back(Constant::getNullValue(Type::UIntTy));
- Indices.push_back(ConstantInt::get(Type::UIntTy, i));
+ Indices.push_back(Constant::getNullValue(Type::Int32Ty));
+ Indices.push_back(ConstantInt::get(Type::Int32Ty, i));
std::string GEPname = "gep_" + inputs[i]->getName();
TerminatorInst *TI = newFunction->begin()->getTerminator();
GetElementPtrInst *GEP = new GetElementPtrInst(AI, Indices, GEPname, TI);
@@ -391,8 +391,8 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
for (unsigned i = 0, e = inputs.size(); i != e; ++i) {
std::vector<Value*> Indices;
- Indices.push_back(Constant::getNullValue(Type::UIntTy));
- Indices.push_back(ConstantInt::get(Type::UIntTy, i));
+ Indices.push_back(Constant::getNullValue(Type::Int32Ty));
+ Indices.push_back(ConstantInt::get(Type::Int32Ty, i));
GetElementPtrInst *GEP =
new GetElementPtrInst(Struct, Indices,
"gep_" + StructValues[i]->getName());
@@ -417,8 +417,8 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
Value *Output = 0;
if (AggregateArgs) {
std::vector<Value*> Indices;
- Indices.push_back(Constant::getNullValue(Type::UIntTy));
- Indices.push_back(ConstantInt::get(Type::UIntTy, FirstOut + i));
+ Indices.push_back(Constant::getNullValue(Type::Int32Ty));
+ Indices.push_back(ConstantInt::get(Type::Int32Ty, FirstOut + i));
GetElementPtrInst *GEP
= new GetElementPtrInst(Struct, Indices,
"gep_reload_" + outputs[i]->getName());
@@ -439,7 +439,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
// Now we can emit a switch statement using the call as a value.
SwitchInst *TheSwitch =
- new SwitchInst(ConstantInt::getNullValue(Type::UShortTy),
+ new SwitchInst(ConstantInt::getNullValue(Type::Int16Ty),
codeReplacer, 0, codeReplacer);
// Since there may be multiple exits from the original region, make the new
@@ -473,14 +473,14 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
brVal = ConstantBool::get(!SuccNum);
break;
default:
- brVal = ConstantInt::get(Type::UShortTy, SuccNum);
+ brVal = ConstantInt::get(Type::Int16Ty, SuccNum);
break;
}
ReturnInst *NTRet = new ReturnInst(brVal, NewTarget);
// Update the switch instruction.
- TheSwitch->addCase(ConstantInt::get(Type::UShortTy, SuccNum),
+ TheSwitch->addCase(ConstantInt::get(Type::Int16Ty, SuccNum),
OldTarget);
// Restore values just before we exit
@@ -518,8 +518,8 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
if (DominatesDef) {
if (AggregateArgs) {
std::vector<Value*> Indices;
- Indices.push_back(Constant::getNullValue(Type::UIntTy));
- Indices.push_back(ConstantInt::get(Type::UIntTy,FirstOut+out));
+ Indices.push_back(Constant::getNullValue(Type::Int32Ty));
+ Indices.push_back(ConstantInt::get(Type::Int32Ty,FirstOut+out));
GetElementPtrInst *GEP =
new GetElementPtrInst(OAI, Indices,
"gep_" + outputs[out]->getName(),
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index b61a85be9d..c49cc75ffb 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -274,7 +274,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG) {
// code with llvm.stacksave/llvm.stackrestore intrinsics.
if (InlinedFunctionInfo.ContainsDynamicAllocas) {
Module *M = Caller->getParent();
- const Type *SBytePtr = PointerType::get(Type::SByteTy);
+ const Type *SBytePtr = PointerType::get(Type::Int8Ty);
// Get the two intrinsics we care about.
Function *StackSave, *StackRestore;
StackSave = M->getOrInsertFunction("llvm.stacksave", SBytePtr, NULL);
diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp
index da0b9ed45c..a842139714 100644
--- a/lib/Transforms/Utils/LowerAllocations.cpp
+++ b/lib/Transforms/Utils/LowerAllocations.cpp
@@ -84,7 +84,7 @@ FunctionPass *llvm::createLowerAllocationsPass(bool LowerMallocArgToInteger) {
// This function is always successful.
//
bool LowerAllocations::doInitialization(Module &M) {
- const Type *SBPTy = PointerType::get(Type::SByteTy);
+ const Type *SBPTy = PointerType::get(Type::Int8Ty);
MallocFunc = M.getNamedFunction("malloc");
FreeFunc = M.getNamedFunction("free");
@@ -120,7 +120,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
// malloc(type) becomes sbyte *malloc(size)
Value *MallocArg;
if (LowerMallocArgToInteger)
- MallocArg = ConstantInt::get(Type::ULongTy, TD.getTypeSize(AllocTy));
+ MallocArg = ConstantInt::get(Type::Int64Ty, TD.getTypeSize(AllocTy));
else
MallocArg = ConstantExpr::getSizeOf(AllocTy);
MallocArg = ConstantExpr::getTruncOrBitCast(cast<Constant>(MallocArg),
@@ -154,7 +154,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
MallocArg = CastInst::createIntegerCast(MallocArg, IntPtrTy,
false /*ZExt*/, "", I);
} else if (MallocFTy->getNumParams() > 0 &&
- MallocFTy->getParamType(0) != Type::UIntTy)
+ MallocFTy->getParamType(0) != Type::Int32Ty)
MallocArg = CastInst::createIntegerCast(
MallocArg, MallocFTy->getParamType(0), false/*ZExt*/, "",I);
MallocArgs.push_back(MallocArg);
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index 361388c7bf..20f5671686 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -110,7 +110,7 @@ FunctionPass *llvm::createLowerInvokePass(const TargetLowering *TLI) {
// doInitialization - Make sure that there is a prototype for abort in the
// current module.
bool LowerInvoke::doInitialization(Module &M) {
- const Type *VoidPtrTy = PointerType::get(Type::SByteTy);
+ const Type *VoidPtrTy = PointerType::get(Type::Int8Ty);
AbortMessage = 0;
if (ExpensiveEHSupport) {
// Insert a type for the linked list of jump buffers.
@@ -139,11 +139,11 @@ bool LowerInvoke::doInitialization(Module &M) {
Constant::getNullValue(PtrJBList),
"llvm.sjljeh.jblist", &M);
}
- SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::IntTy,
+ SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::Int32Ty,
PointerType::get(JmpBufTy), (Type *)0);
LongJmpFn = M.getOrInsertFunction("llvm.longjmp", Type::VoidTy,
PointerType::get(JmpBufTy),
- Type::IntTy, (Type *)0);
+ Type::Int32Ty, (Type *)0);
}
// We need the 'write' and 'abort' functions for both models.
@@ -163,8 +163,8 @@ bool LowerInvoke::doInitialization(Module &M) {
else
WriteFn = 0;
} else {
- WriteFn = M.getOrInsertFunction("write", Type::VoidTy, Type::IntTy,
- VoidPtrTy, Type::IntTy, (Type *)0);
+ WriteFn = M.getOrInsertFunction("write", Type::VoidTy, Type::Int32Ty,
+ VoidPtrTy, Type::Int32Ty, (Type *)0);
}
return true;
}
@@ -181,7 +181,7 @@ void LowerInvoke::createAbortMessage() {
GlobalVariable *MsgGV = new GlobalVariable(Msg->getType(), true,
GlobalValue::InternalLinkage,
Msg, "abortmsg", &M);
- std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::IntTy));
+ std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::Int32Ty));
AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, GEPIdx);
} else {
// The abort message for cheap EH support tells the user that EH is not
@@ -194,7 +194,7 @@ void LowerInvoke::createAbortMessage() {
GlobalVariable *MsgGV = new GlobalVariable(Msg->getType(), true,
GlobalValue::InternalLinkage,
Msg, "abortmsg", &M);
- std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::IntTy));
+ std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::Int32Ty));
AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, GEPIdx);
}
}
@@ -206,9 +206,9 @@ void LowerInvoke::writeAbortMessage(Instruction *IB) {
// These are the arguments we WANT...
std::vector<Value*> Args;
- Args.push_back(ConstantInt::get(Type::IntTy, 2));
+ Args.push_back(ConstantInt::get(Type::Int32Ty, 2));
Args.push_back(AbortMessage);
- Args.push_back(ConstantInt::get(Type::IntTy, AbortMessageLength));
+ Args.push_back(ConstantInt::get(Type::Int32Ty, AbortMessageLength));
// If the actual declaration of write disagrees, insert casts as
// appropriate.
@@ -274,7 +274,7 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) {
void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo,
AllocaInst *InvokeNum,
SwitchInst *CatchSwitch) {
- ConstantInt *InvokeNoC = ConstantInt::get(Type::UIntTy, InvokeNo);
+ ConstantInt *InvokeNoC = ConstantInt::get(Type::Int32Ty, InvokeNo);
// Insert a store of the invoke num before the invoke and store zero into the
// location afterward.
@@ -283,7 +283,7 @@ void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo,
BasicBlock::iterator NI = II->getNormalDest()->begin();
while (isa<PHINode>(NI)) ++NI;
// nonvolatile.
- new StoreInst(Constant::getNullValue(Type::UIntTy), InvokeNum, false, NI);
+ new StoreInst(Constant::getNullValue(Type::Int32Ty), InvokeNum, false, NI);
// Add a switch case to our unwind block.
CatchSwitch->addCase(InvokeNoC, II->getUnwindDest());
@@ -470,8 +470,8 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
new AllocaInst(JBLinkTy, 0, Align, "jblink", F.begin()->begin());
std::vector<Value*> Idx;
- Idx.push_back(Constant::getNullValue(Type::IntTy));
- Idx.push_back(ConstantInt::get(Type::UIntTy, 1));
+ Idx.push_back(Constant::getNullValue(Type::Int32Ty));
+ Idx.push_back(ConstantInt::get(Type::Int32Ty, 1));
OldJmpBufPtr = new GetElementPtrInst(JmpBuf, Idx, "OldBuf",
EntryBB->getTerminator());
@@ -489,9 +489,9 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
// Create an alloca which keeps track of which invoke is currently
// executing. For normal calls it contains zero.
- AllocaInst *InvokeNum = new AllocaInst(Type::UIntTy, 0, "invokenum",
+ AllocaInst *InvokeNum = new AllocaInst(Type::Int32Ty, 0, "invokenum",
EntryBB->begin());
- new StoreInst(ConstantInt::get(Type::UIntTy, 0), InvokeNum, true,
+ new StoreInst(ConstantInt::get(Type::Int32Ty, 0), InvokeNum, true,
EntryBB->getTerminator());
// Insert a load in the Catch block, and a switch on its value. By default,
@@ -510,7 +510,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
BasicBlock *ContBlock = EntryBB->splitBasicBlock(EntryBB->getTerminator(),
"setjmp.cont");
- Idx[1] = ConstantInt::get(Type::UIntTy, 0);
+ Idx[1] = ConstantInt::get(Type::Int32Ty, 0);
Value *JmpBufPtr = new GetElementPtrInst(JmpBuf, Idx, "TheJmpBuf",
EntryBB->getTerminator());
Value *SJRet = new CallInst(SetJmpFn, JmpBufPtr, "sjret",
@@ -559,10 +559,10 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
// Create the block to do the longjmp.
// Get a pointer to the jmpbuf and longjmp.
std::vector<Value*> Idx;
- Idx.push_back(Constant::getNullValue(Type::IntTy));
- Idx.push_back(ConstantInt::get(Type::UIntTy, 0));
+ Idx.push_back(Constant::getNullValue(Type::Int32Ty));
+ Idx.push_back(ConstantInt::get(Type::Int32Ty, 0));
Idx[0] = new GetElementPtrInst(BufPtr, Idx, "JmpBuf", UnwindBlock);
- Idx[1] = ConstantInt::get(Type::IntTy, 1);
+ Idx[1] = ConstantInt::get(Type::Int32Ty, 1);
new CallInst(LongJmpFn, Idx, "", UnwindBlock);
new UnreachableInst(UnwindBlock);
diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp
index b2974a98c8..bcbadd0040 100644
--- a/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/lib/Transforms/Utils/LowerSwitch.cpp
@@ -59,9 +59,7 @@ namespace {
const ConstantInt* CI1 = cast<const ConstantInt>(C1.first);
const ConstantInt* CI2 = cast<const ConstantInt>(C2.first);
- if (CI1->getType()->isUnsigned())
- return CI1->getZExtValue() < CI2->getZExtValue();
- return CI1->getSExtValue() < CI2->getSExtValue();
+ return CI1->getZExtValue() < CI2->getZExtValue();
}
};