fix a crash on code that uses the result value of __builtin___memcpy_chk.

llvm-svn: 129892
This commit is contained in:
Chris Lattner 2011-04-20 23:14:50 +00:00
parent d70ca52081
commit 54fd1a1ad3
2 changed files with 9 additions and 3 deletions

View File

@ -556,7 +556,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
Value *Src = EmitScalarExpr(E->getArg(1));
Value *SizeVal = llvm::ConstantInt::get(Builder.getContext(), Size);
Builder.CreateMemCpy(Dest, Src, SizeVal, 1, false);
return RValue::get(0);
return RValue::get(Dest);
}
case Builtin::BI__builtin_objc_memmove_collectable: {
@ -581,7 +581,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
Value *Src = EmitScalarExpr(E->getArg(1));
Value *SizeVal = llvm::ConstantInt::get(Builder.getContext(), Size);
Builder.CreateMemMove(Dest, Src, SizeVal, 1, false);
return RValue::get(0);
return RValue::get(Dest);
}
case Builtin::BImemmove:
@ -616,7 +616,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
Value *SizeVal = llvm::ConstantInt::get(Builder.getContext(), Size);
Builder.CreateMemSet(Address, ByteVal, SizeVal, 1, false);
return RValue::get(0);
return RValue::get(Address);
}
case Builtin::BI__builtin_dwarf_cfa: {
// The offset in bytes from the first argument to the CFA.

View File

@ -42,3 +42,9 @@ void test4(char *P, char *Q) {
void test5(char *P, char *Q) {
__builtin___memmove_chk(P, Q, 128, 128);
}
// CHECK: @test6
// CHECK: call void @llvm.memcpy
int test6(char *X) {
return __builtin___memcpy_chk(X, X, 42, 42) != 0;
}