r317776 - Fix a bug with the use of __builtin_bzero in a conditional expression.
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 9 01:32:32 PST 2017
Author: rjmccall
Date: Thu Nov 9 01:32:32 2017
New Revision: 317776
URL: http://llvm.org/viewvc/llvm-project?rev=317776&view=rev
Log:
Fix a bug with the use of __builtin_bzero in a conditional expression.
Patch by Bharathi Seshadri!
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins.c
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=317776&r1=317775&r2=317776&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Nov 9 01:32:32 2017
@@ -1431,7 +1431,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
EmitNonNullArgCheck(RValue::get(Dest.getPointer()), E->getArg(0)->getType(),
E->getArg(0)->getExprLoc(), FD, 0);
Builder.CreateMemSet(Dest, Builder.getInt8(0), SizeVal, false);
- return RValue::get(Dest.getPointer());
+ return RValue::get(nullptr);
}
case Builtin::BImemcpy:
case Builtin::BI__builtin_memcpy: {
Modified: cfe/trunk/test/CodeGen/builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=317776&r1=317775&r2=317776&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Thu Nov 9 01:32:32 2017
@@ -176,6 +176,19 @@ void bar() {
}
// CHECK: }
+// CHECK-LABEL: define void @test_conditional_bzero
+void test_conditional_bzero() {
+ char dst[20];
+ int _sz = 20, len = 20;
+ return (_sz
+ ? ((_sz >= len)
+ ? __builtin_bzero(dst, len)
+ : foo())
+ : __builtin_bzero(dst, len));
+ // CHECK: call void @llvm.memset
+ // CHECK: call void @llvm.memset
+ // CHECK-NOT: phi
+}
// CHECK-LABEL: define void @test_float_builtins
void test_float_builtins(float F, double D, long double LD) {
More information about the cfe-commits
mailing list