aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
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/Transforms
parent05e52a1b35e7feb359a176af462591697c4d9647 (diff)
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/Transforms')
-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
29 files changed, 379 insertions, 453 deletions
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)
+