summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/RaiseAllocations.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-08-13 21:58:54 +0000
committerOwen Anderson <resistor@mac.com>2009-08-13 21:58:54 +0000
commit1d0be15f89cb5056e20e2d24faa8d6afb1573bca (patch)
tree2cdabe223bfce83bd12e10dd557147a2f68c9bf8 /lib/Transforms/IPO/RaiseAllocations.cpp
parentd163e8b14c8aa5bbbb129e3f0dffdbe7213a3c72 (diff)
downloadllvm-1d0be15f89cb5056e20e2d24faa8d6afb1573bca.tar.gz
llvm-1d0be15f89cb5056e20e2d24faa8d6afb1573bca.tar.bz2
llvm-1d0be15f89cb5056e20e2d24faa8d6afb1573bca.tar.xz
Push LLVMContexts through the IntegerType APIs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78948 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/RaiseAllocations.cpp')
-rw-r--r--lib/Transforms/IPO/RaiseAllocations.cpp43
1 files changed, 26 insertions, 17 deletions
diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp
index 0ef0991637..7b4ad27694 100644
--- a/lib/Transforms/IPO/RaiseAllocations.cpp
+++ b/lib/Transforms/IPO/RaiseAllocations.cpp
@@ -77,22 +77,26 @@ void RaiseAllocations::doInitialization(Module &M) {
// Get the expected prototype for malloc
const FunctionType *Malloc1Type =
- FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
- std::vector<const Type*>(1, Type::Int64Ty), false);
+ FunctionType::get(PointerType::getUnqual(Type::getInt8Ty(M.getContext())),
+ std::vector<const Type*>(1,
+ Type::getInt64Ty(M.getContext())), false);
// Chck to see if we got the expected malloc
if (TyWeHave != Malloc1Type) {
// Check to see if the prototype is wrong, giving us i8*(i32) * malloc
// This handles the common declaration of: 'void *malloc(unsigned);'
const FunctionType *Malloc2Type =
- FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
- std::vector<const Type*>(1, Type::Int32Ty), false);
+ FunctionType::get(PointerType::getUnqual(
+ Type::getInt8Ty(M.getContext())),
+ std::vector<const Type*>(1,
+ Type::getInt32Ty(M.getContext())), false);
if (TyWeHave != Malloc2Type) {
// Check to see if the prototype is missing, giving us
// i8*(...) * malloc
// This handles the common declaration of: 'void *malloc();'
const FunctionType *Malloc3Type =
- FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
+ FunctionType::get(PointerType::getUnqual(
+ Type::getInt8Ty(M.getContext())),
true);
if (TyWeHave != Malloc3Type)
// Give up
@@ -106,22 +110,24 @@ void RaiseAllocations::doInitialization(Module &M) {
const FunctionType* TyWeHave = FreeFunc->getFunctionType();
// Get the expected prototype for void free(i8*)
- const FunctionType *Free1Type = FunctionType::get(Type::VoidTy,
- std::vector<const Type*>(1, PointerType::getUnqual(Type::Int8Ty)),
- false);
+ const FunctionType *Free1Type =
+ FunctionType::get(Type::getVoidTy(M.getContext()),
+ std::vector<const Type*>(1, PointerType::getUnqual(
+ Type::getInt8Ty(M.getContext()))),
+ false);
if (TyWeHave != Free1Type) {
// Check to see if the prototype was forgotten, giving us
// void (...) * free
// This handles the common forward declaration of: 'void free();'
- const FunctionType* Free2Type = FunctionType::get(Type::VoidTy,
- true);
+ const FunctionType* Free2Type =
+ FunctionType::get(Type::getVoidTy(M.getContext()), true);
if (TyWeHave != Free2Type) {
// One last try, check to see if we can find free as
// int (...)* free. This handles the case where NOTHING was declared.
- const FunctionType* Free3Type = FunctionType::get(Type::Int32Ty,
- true);
+ const FunctionType* Free3Type =
+ FunctionType::get(Type::getInt32Ty(M.getContext()), true);
if (TyWeHave != Free3Type) {
// Give up.
@@ -163,12 +169,15 @@ bool RaiseAllocations::runOnModule(Module &M) {
// If no prototype was provided for malloc, we may need to cast the
// source size.
- if (Source->getType() != Type::Int32Ty)
+ if (Source->getType() != Type::getInt32Ty(M.getContext()))
Source =
- CastInst::CreateIntegerCast(Source, Type::Int32Ty, false/*ZExt*/,
+ CastInst::CreateIntegerCast(Source,
+ Type::getInt32Ty(M.getContext()),
+ false/*ZExt*/,
"MallocAmtCast", I);
- MallocInst *MI = new MallocInst(Type::Int8Ty, Source, "", I);
+ MallocInst *MI = new MallocInst(Type::getInt8Ty(M.getContext()),
+ Source, "", I);
MI->takeName(I);
I->replaceAllUsesWith(MI);
@@ -220,7 +229,7 @@ bool RaiseAllocations::runOnModule(Module &M) {
Value *Source = *CS.arg_begin();
if (!isa<PointerType>(Source->getType()))
Source = new IntToPtrInst(Source,
- PointerType::getUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::getInt8Ty(M.getContext())),
"FreePtrCast", I);
new FreeInst(Source, I);
@@ -230,7 +239,7 @@ bool RaiseAllocations::runOnModule(Module &M) {
BranchInst::Create(II->getNormalDest(), I);
// Delete the old call site
- if (I->getType() != Type::VoidTy)
+ if (I->getType() != Type::getVoidTy(M.getContext()))
I->replaceAllUsesWith(UndefValue::get(I->getType()));
I->eraseFromParent();
Changed = true;