mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 21:18:19 +00:00
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:
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user