[llvm-commits] [llvm] r99263 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCalls.cpp test/Transforms/InstCombine/objsize.ll

Evan Cheng evan.cheng at apple.com
Mon Mar 22 23:06:10 PDT 2010


Author: evancheng
Date: Tue Mar 23 01:06:09 2010
New Revision: 99263

URL: http://llvm.org/viewvc/llvm-project?rev=99263&view=rev
Log:
Fix an incorrect logic causing instcombine to miss some _chk -> non-chk transformations.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
    llvm/trunk/test/Transforms/InstCombine/objsize.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=99263&r1=99262&r2=99263&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Tue Mar 23 01:06:09 2010
@@ -766,7 +766,7 @@
         return SizeCI->getZExtValue() >=
                GetStringLength(CI->getOperand(SizeArgOp));
       if (ConstantInt *Arg = dyn_cast<ConstantInt>(CI->getOperand(SizeArgOp)))
-        return SizeCI->getZExtValue() <= Arg->getZExtValue();
+        return SizeCI->getZExtValue() >= Arg->getZExtValue();
     }
     return false;
   }

Modified: llvm/trunk/test/Transforms/InstCombine/objsize.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/objsize.ll?rev=99263&r1=99262&r2=99263&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/objsize.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/objsize.ll Tue Mar 23 01:06:09 2010
@@ -118,6 +118,7 @@
   ret i32 0
 }
 
+; rdar://7782496
 @s = external global i8*
 
 define void @test5(i32 %n) nounwind ssp {
@@ -127,11 +128,23 @@
   %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false)
   %2 = load i8** @s, align 8
 ; CHECK-NOT: @llvm.objectsize
-; CHECK: @__memcpy_chk(i8* %0, i8* %1, i32 10, i32 20)
+; CHECK: @llvm.memcpy.i32(i8* %0, i8* %1, i32 10, i32 1)
   %3 = tail call i8* @__memcpy_chk(i8* %0, i8* %2, i32 10, i32 %1) nounwind
   ret void
 }
 
+define void @test6(i32 %n) nounwind ssp {
+; CHECK: @test6
+entry:
+  %0 = tail call noalias i8* @malloc(i32 20) nounwind
+  %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false)
+  %2 = load i8** @s, align 8
+; CHECK-NOT: @llvm.objectsize
+; CHECK: @__memcpy_chk(i8* %0, i8* %1, i32 30, i32 20)
+  %3 = tail call i8* @__memcpy_chk(i8* %0, i8* %2, i32 30, i32 %1) nounwind
+  ret void
+}
+
 declare i8* @__memset_chk(i8*, i32, i64, i64) nounwind
 
 declare noalias i8* @malloc(i32) nounwind





More information about the llvm-commits mailing list