Fix a bug with the use of __builtin_bzero in a conditional expression.

Patch by Bharathi Seshadri!

llvm-svn: 317776
This commit is contained in:
John McCall 2017-11-09 09:32:32 +00:00
parent 5bfa5ffe5e
commit 26d55e0346
2 changed files with 14 additions and 1 deletions

View File

@ -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: {

View File

@ -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) {