aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Utils')
-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
5 files changed, 36 insertions, 38 deletions
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();
}
};