aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/InstCombine/InstCombineCalls.cpp2
-rw-r--r--test/Transforms/InstCombine/objsize.ll15
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 65f2e15d27..76c815da86 100644
--- a/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -766,7 +766,7 @@ protected:
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;
}
diff --git a/test/Transforms/InstCombine/objsize.ll b/test/Transforms/InstCombine/objsize.ll
index cd7b7c8067..f8b2ffca01 100644
--- a/test/Transforms/InstCombine/objsize.ll
+++ b/test/Transforms/InstCombine/objsize.ll
@@ -118,6 +118,7 @@ entry:
ret i32 0
}
+; rdar://7782496
@s = external global i8*
define void @test5(i32 %n) nounwind ssp {
@@ -127,11 +128,23 @@ entry:
%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