From: Reid Spencer Date: Tue, 12 Dec 2006 09:17:08 +0000 (+0000) Subject: Fix the casting for the computation of the Malloc size. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=daa8e3c2633aa876b6cd572f5528cfe2bdb0ccc3;p=oota-llvm.git 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 --- diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index 40a4dc0d305..d011d754757 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/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);