mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-21 21:29:41 +00:00
Fix the casting for the computation of the Malloc size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32477 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b15974a65c
commit
daa8e3c263
@ -122,15 +122,15 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
|
|||||||
MallocArg = ConstantInt::get(Type::ULongTy, TD.getTypeSize(AllocTy));
|
MallocArg = ConstantInt::get(Type::ULongTy, TD.getTypeSize(AllocTy));
|
||||||
else
|
else
|
||||||
MallocArg = ConstantExpr::getSizeOf(AllocTy);
|
MallocArg = ConstantExpr::getSizeOf(AllocTy);
|
||||||
MallocArg = ConstantExpr::getIntegerCast(cast<Constant>(MallocArg),
|
MallocArg = ConstantExpr::getTruncOrBitCast(cast<Constant>(MallocArg),
|
||||||
IntPtrTy, true /*SExt*/);
|
IntPtrTy);
|
||||||
|
|
||||||
if (MI->isArrayAllocation()) {
|
if (MI->isArrayAllocation()) {
|
||||||
if (isa<ConstantInt>(MallocArg) &&
|
if (isa<ConstantInt>(MallocArg) &&
|
||||||
cast<ConstantInt>(MallocArg)->getZExtValue() == 1) {
|
cast<ConstantInt>(MallocArg)->getZExtValue() == 1) {
|
||||||
MallocArg = MI->getOperand(0); // Operand * 1 = Operand
|
MallocArg = MI->getOperand(0); // Operand * 1 = Operand
|
||||||
} else if (Constant *CO = dyn_cast<Constant>(MI->getOperand(0))) {
|
} else if (Constant *CO = dyn_cast<Constant>(MI->getOperand(0))) {
|
||||||
CO = ConstantExpr::getIntegerCast(CO, IntPtrTy, true /*SExt*/);
|
CO = ConstantExpr::getIntegerCast(CO, IntPtrTy, false /*ZExt*/);
|
||||||
MallocArg = ConstantExpr::getMul(CO, cast<Constant>(MallocArg));
|
MallocArg = ConstantExpr::getMul(CO, cast<Constant>(MallocArg));
|
||||||
} else {
|
} else {
|
||||||
Value *Scale = MI->getOperand(0);
|
Value *Scale = MI->getOperand(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user