summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-09-13 22:28:45 +0000
committerChris Lattner <sabre@nondot.org>2002-09-13 22:28:45 +0000
commit05804b74590ab8714bd7695d8cd0d98819c092f9 (patch)
tree451faeda1278aa0dd6af79e54834bc35f6ba8572 /lib
parent5fefb252532b1bcd8891749c2df16ba2f1ce0809 (diff)
downloadllvm-05804b74590ab8714bd7695d8cd0d98819c092f9.tar.gz
llvm-05804b74590ab8714bd7695d8cd0d98819c092f9.tar.bz2
llvm-05804b74590ab8714bd7695d8cd0d98819c092f9.tar.xz
Change the MallocInst & AllocaInst ctors to take the allocated type, not the
pointer type returned. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3710 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AsmParser/llvmAsmParser.y11
-rw-r--r--lib/Transforms/ExprTypeConvert.cpp2
-rw-r--r--lib/Transforms/IPO/RaiseAllocations.cpp3
3 files changed, 6 insertions, 10 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index 34929c0bbf..de5f469d11 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -1630,22 +1630,19 @@ IndexList : ',' ValueRefList {
};
MemoryInst : MALLOC Types {
- $$ = new MallocInst(PointerType::get(*$2));
+ $$ = new MallocInst(*$2);
delete $2;
}
| MALLOC Types ',' UINT ValueRef {
- const Type *Ty = PointerType::get(*$2);
- $$ = new MallocInst(Ty, getVal($4, $5));
+ $$ = new MallocInst(*$2, getVal($4, $5));
delete $2;
}
| ALLOCA Types {
- $$ = new AllocaInst(PointerType::get(*$2));
+ $$ = new AllocaInst(*$2);
delete $2;
}
| ALLOCA Types ',' UINT ValueRef {
- const Type *Ty = PointerType::get(*$2);
- Value *ArrSize = getVal($4, $5);
- $$ = new AllocaInst(Ty, ArrSize);
+ $$ = new AllocaInst(*$2, getVal($4, $5));
delete $2;
}
| FREE ResolvedVal {
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index 4abbbeb167..ab4edf3366 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -125,7 +125,7 @@ static Instruction *ConvertMallocToType(MallocInst *MI, const Type *Ty,
}
assert(AllocTy == Ty);
- return new MallocInst(AllocTy, Expr.Var, Name);
+ return new MallocInst(AllocTy->getElementType(), Expr.Var, Name);
}
diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp
index 241e1f55ee..bf83007557 100644
--- a/lib/Transforms/IPO/RaiseAllocations.cpp
+++ b/lib/Transforms/IPO/RaiseAllocations.cpp
@@ -113,7 +113,6 @@ bool RaiseAllocations::runOnBasicBlock(BasicBlock &BB) {
if (CallInst *CI = dyn_cast<CallInst>(I)) {
if (CI->getCalledValue() == MallocFunc) { // Replace call to malloc?
- const Type *PtrSByte = PointerType::get(Type::SByteTy);
Value *Source = CI->getOperand(1);
// If no prototype was provided for malloc, we may need to cast the
@@ -122,7 +121,7 @@ bool RaiseAllocations::runOnBasicBlock(BasicBlock &BB) {
Source = new CastInst(Source, Type::UIntTy, "MallocAmtCast", BI);
std::string Name(CI->getName()); CI->setName("");
- BI = new MallocInst(PtrSByte, Source, Name, BI);
+ BI = new MallocInst(Type::SByteTy, Source, Name, BI);
CI->replaceAllUsesWith(BI);
BIL.erase(I);
Changed = true;