[llvm-commits] CVS: llvm/lib/Transforms/Utils/LowerAllocations.cpp

Reid Spencer reid at x10sys.com
Tue Dec 12 01:17:24 PST 2006



Changes in directory llvm/lib/Transforms/Utils:

LowerAllocations.cpp updated: 1.65 -> 1.66
---
Log message:

Fix the casting for the computation of the Malloc size.


---
Diffs of the changes:  (+3 -3)

 LowerAllocations.cpp |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


Index: llvm/lib/Transforms/Utils/LowerAllocations.cpp
diff -u llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.65 llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.66
--- llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.65	Mon Dec 11 23:05:00 2006
+++ llvm/lib/Transforms/Utils/LowerAllocations.cpp	Tue Dec 12 03:17:08 2006
@@ -122,15 +122,15 @@
         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);






More information about the llvm-commits mailing list