diff options
author | John McCall <rjmccall@apple.com> | 2017-11-09 09:32:32 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2017-11-09 09:32:32 +0000 |
commit | 26d55e0346964a46978c873b4d4bde01df4ea977 (patch) | |
tree | dca29012466e118aebaa0c15ffcc43f7a8df546a | |
parent | 5bfa5ffe5ebe515caa22ad65f62df124ed2a7c7c (diff) | |
download | bcm5719-llvm-26d55e0346964a46978c873b4d4bde01df4ea977.tar.gz bcm5719-llvm-26d55e0346964a46978c873b4d4bde01df4ea977.zip |
Fix a bug with the use of __builtin_bzero in a conditional expression.
Patch by Bharathi Seshadri!
llvm-svn: 317776
-rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 2 | ||||
-rw-r--r-- | clang/test/CodeGen/builtins.c | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 369240f316c..2d1b4f40dc5 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -1431,7 +1431,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, 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: { diff --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c index 86bee451ecb..0207bb6c9fe 100644 --- a/clang/test/CodeGen/builtins.c +++ b/clang/test/CodeGen/builtins.c @@ -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) { |