[llvm-commits] [llvm-gcc-4.2] r67693 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Evan Cheng evan.cheng at apple.com
Wed Mar 25 10:44:20 PDT 2009


Author: evancheng
Date: Wed Mar 25 12:44:20 2009
New Revision: 67693

URL: http://llvm.org/viewvc/llvm-project?rev=67693&view=rev
Log:
Update per feedback.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=67693&r1=67692&r2=67693&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Mar 25 12:44:20 2009
@@ -5113,8 +5113,8 @@
 /// plain non-checking calls. If the size of the argument is either -1 (unknown)
 /// or large enough to ensure no overflow (> len), then it's safe to do so.
 static bool OptimizeIntoPlainBuiltIn(tree exp, Value *Len, Value *Size) {
-  if (BitCastInst *BC = dyn_cast<BitCastInst>(Size))
-    Size = BC->getOperand(0);
+  if (BitCastInst *SizeBC = dyn_cast<BitCastInst>(Size))
+    Size = SizeBC->getOperand(0);
   ConstantInt *SizeCI = dyn_cast<ConstantInt>(Size);
   if (!SizeCI)
     return false;
@@ -5122,10 +5122,12 @@
     // If size is -1, convert to plain memcpy, etc.
     return true;
 
+  if (BitCastInst *LenBC = dyn_cast<BitCastInst>(Len))
+    Len = LenBC->getOperand(0);
   ConstantInt *LenCI = dyn_cast<ConstantInt>(Len);
   if (!LenCI)
     return false;
-  if (LenCI->getZExtValue() >= SizeCI->getZExtValue()) {
+  if (SizeCI->getValue().ult(LenCI->getValue())) {
     location_t locus = EXPR_LOCATION(exp);
     warning (0, "%Hcall to %D will always overflow destination buffer",
              &locus, get_callee_fndecl(exp));





More information about the llvm-commits mailing list