[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

Andrew Lenharth alenhar2 at cs.uiuc.edu
Tue Jun 27 18:02:05 PDT 2006



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.491 -> 1.492
---
Log message:

Catch more function pointer casting problems
Remove the Function pointer cast in these calls, converting it to
a cast of argument.
%tmp60 = tail call int cast (int (ulong)* %str to int (int)*)( int 10 )
%tmp60 = tail call int cast (int (ulong)* %str to int (int)*)( uint %tmp51 )



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

 InstructionCombining.cpp |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.491 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.492
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.491	Thu Jun 15 14:07:26 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Tue Jun 27 20:01:52 2006
@@ -6048,7 +6048,15 @@
   CallSite::arg_iterator AI = CS.arg_begin();
   for (unsigned i = 0, e = NumCommonArgs; i != e; ++i, ++AI) {
     const Type *ParamTy = FT->getParamType(i);
-    bool isConvertible = (*AI)->getType()->isLosslesslyConvertibleTo(ParamTy);
+    const Type *ActTy = (*AI)->getType();
+    ConstantSInt* c = dyn_cast<ConstantSInt>(*AI);
+    //Either we can cast directly, or we can upconvert the argument
+    bool isConvertible = ActTy->isLosslesslyConvertibleTo(ParamTy) ||
+      (ParamTy->isIntegral() && ActTy->isIntegral() &&
+       ParamTy->isSigned() == ActTy->isSigned() &&
+       ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize()) ||
+      (c && ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize() &&
+       c->getValue() > 0);
     if (Callee->isExternal() && !isConvertible) return false;
   }
 






More information about the llvm-commits mailing list