Index: lib/CodeGen/CGBuiltin.cpp =================================================================== --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -1431,7 +1431,7 @@ 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: { Index: test/CodeGen/builtins.c =================================================================== --- test/CodeGen/builtins.c +++ test/CodeGen/builtins.c @@ -176,6 +176,19 @@ } // 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) {