From 41cb269a2b1e3e05c34f331964a51881bbaf232c Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Tue, 12 Dec 2006 09:17:08 +0000 Subject: [PATCH] Fix the casting for the computation of the Malloc size. llvm-svn: 32477 --- llvm/lib/Transforms/Utils/LowerAllocations.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/Utils/LowerAllocations.cpp b/llvm/lib/Transforms/Utils/LowerAllocations.cpp index 40a4dc0d3055..d011d7547574 100644 --- a/llvm/lib/Transforms/Utils/LowerAllocations.cpp +++ b/llvm/lib/Transforms/Utils/LowerAllocations.cpp @@ -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(MallocArg), - IntPtrTy, true /*SExt*/); + MallocArg = ConstantExpr::getTruncOrBitCast(cast(MallocArg), + IntPtrTy); if (MI->isArrayAllocation()) { if (isa(MallocArg) && cast(MallocArg)->getZExtValue() == 1) { MallocArg = MI->getOperand(0); // Operand * 1 = Operand } else if (Constant *CO = dyn_cast(MI->getOperand(0))) { - CO = ConstantExpr::getIntegerCast(CO, IntPtrTy, true /*SExt*/); + CO = ConstantExpr::getIntegerCast(CO, IntPtrTy, false /*ZExt*/); MallocArg = ConstantExpr::getMul(CO, cast(MallocArg)); } else { Value *Scale = MI->getOperand(0);