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

Reid Spencer reid at x10sys.com
Mon Dec 11 21:05:24 PST 2006



Changes in directory llvm/lib/Transforms/Utils:

LowerAllocations.cpp updated: 1.64 -> 1.65
LowerInvoke.cpp updated: 1.45 -> 1.46
---
Log message:

Change inferred getCast into specific getCast. Passes all tests.


---
Diffs of the changes:  (+9 -4)

 LowerAllocations.cpp |    5 +++--
 LowerInvoke.cpp      |    8 ++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)


Index: llvm/lib/Transforms/Utils/LowerAllocations.cpp
diff -u llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.64 llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.65
--- llvm/lib/Transforms/Utils/LowerAllocations.cpp:1.64	Wed Dec  6 11:46:33 2006
+++ llvm/lib/Transforms/Utils/LowerAllocations.cpp	Mon Dec 11 23:05:00 2006
@@ -122,14 +122,15 @@
         MallocArg = ConstantInt::get(Type::ULongTy, TD.getTypeSize(AllocTy));
       else
         MallocArg = ConstantExpr::getSizeOf(AllocTy);
-      MallocArg = ConstantExpr::getCast(cast<Constant>(MallocArg), IntPtrTy);
+      MallocArg = ConstantExpr::getIntegerCast(cast<Constant>(MallocArg), 
+                                               IntPtrTy, true /*SExt*/);
 
       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::getCast(CO, IntPtrTy);
+          CO = ConstantExpr::getIntegerCast(CO, IntPtrTy, true /*SExt*/);
           MallocArg = ConstantExpr::getMul(CO, cast<Constant>(MallocArg));
         } else {
           Value *Scale = MI->getOperand(0);


Index: llvm/lib/Transforms/Utils/LowerInvoke.cpp
diff -u llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.45 llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.46
--- llvm/lib/Transforms/Utils/LowerInvoke.cpp:1.45	Wed Dec  6 11:46:33 2006
+++ llvm/lib/Transforms/Utils/LowerInvoke.cpp	Mon Dec 11 23:05:00 2006
@@ -215,8 +215,12 @@
     unsigned NumArgs = FT->getNumParams();
     for (unsigned i = 0; i != 3; ++i)
       if (i < NumArgs && FT->getParamType(i) != Args[i]->getType())
-        Args[i] = ConstantExpr::getCast(cast<Constant>(Args[i]),
-                                        FT->getParamType(i));
+        if (Args[i]->getType()->isInteger())
+          Args[i] = ConstantExpr::getIntegerCast(cast<Constant>(Args[i]),
+                                                 FT->getParamType(i), true);
+        else
+          Args[i] = ConstantExpr::getBitCast(cast<Constant>(Args[i]),
+                                             FT->getParamType(i));
 
     (new CallInst(WriteFn, Args, "", IB))->setTailCall();
   }






More information about the llvm-commits mailing list