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
This commit is contained in:
Chris Lattner
2002-09-13 22:28:45 +00:00
parent 5fefb25253
commit 05804b7459
3 changed files with 6 additions and 10 deletions
+4 -7
View File
@@ -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 {
+1 -1
View File
@@ -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);
}
+1 -2
View File
@@ -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;