forked from OSchip/llvm-project
Fix the casting for the computation of the Malloc size.
llvm-svn: 32477
This commit is contained in:
parent
0c0b78c18e
commit
41cb269a2b
|
@ -122,15 +122,15 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
|
|||
MallocArg = ConstantInt::get(Type::ULongTy, TD.getTypeSize(AllocTy));
|
||||
else
|
||||
MallocArg = ConstantExpr::getSizeOf(AllocTy);
|
||||
MallocArg = ConstantExpr::getIntegerCast(cast<Constant>(MallocArg),
|
||||
IntPtrTy, true /*SExt*/);
|
||||
MallocArg = ConstantExpr::getTruncOrBitCast(cast<Constant>(MallocArg),
|
||||
IntPtrTy);
|
||||
|
||||
if (MI->isArrayAllocation()) {
|
||||
if (isa<ConstantInt>(MallocArg) &&
|
||||
cast<ConstantInt>(MallocArg)->getZExtValue() == 1) {
|
||||
MallocArg = MI->getOperand(0); // Operand * 1 = Operand
|
||||
} 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));
|
||||
} else {
|
||||
Value *Scale = MI->getOperand(0);
|
||||
|
|
Loading…
Reference in New Issue