diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index a4f26a6f0eb19..27183c69b7ea3 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -4011,7 +4011,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, EmitNonNullArgCheck(RValue::get(Dest.getPointer()), E->getArg(1)->getType(), E->getArg(1)->getExprLoc(), FD, 0); Builder.CreateMemMove(Dest, Src, SizeVal, false); - return RValue::get(Dest.getPointer()); + return RValue::get(nullptr); } case Builtin::BImemcpy: diff --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c index ce1182b724dcc..ed03233b6f1a9 100644 --- a/clang/test/CodeGen/builtins.c +++ b/clang/test/CodeGen/builtins.c @@ -202,6 +202,21 @@ void test_conditional_bzero(void) { // CHECK-NOT: phi } +// CHECK-LABEL: define{{.*}} void @test_conditional_bcopy +void test_conditional_bcopy(void) { + char dst[20]; + char src[20]; + int _sz = 20, len = 20; + return (_sz + ? ((_sz >= len) + ? __builtin_bcopy(src, dst, len) + : foo()) + : __builtin_bcopy(src, dst, len)); + // CHECK: call void @llvm.memmove + // CHECK: call void @llvm.memmove + // CHECK-NOT: phi +} + // CHECK-LABEL: define{{.*}} void @test_float_builtins void test_float_builtins(__fp16 *H, float F, double D, long double LD) { volatile int res;