diff options
| author | Chris Lattner <sabre@nondot.org> | 2011-04-20 23:14:50 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2011-04-20 23:14:50 +0000 |
| commit | 54fd1a1ad3e603f56c8409de0a87c175b0a8ea2c (patch) | |
| tree | 357c5f82fd7049a1cdfd4c12a9c57b8ea218c41a | |
| parent | d70ca52081a6a01c634dfb112f04025704e0bd83 (diff) | |
| download | bcm5719-llvm-54fd1a1ad3e603f56c8409de0a87c175b0a8ea2c.tar.gz bcm5719-llvm-54fd1a1ad3e603f56c8409de0a87c175b0a8ea2c.zip | |
fix a crash on code that uses the result value of __builtin___memcpy_chk.
llvm-svn: 129892
| -rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 6 | ||||
| -rw-r--r-- | clang/test/CodeGen/builtin-memfns.c | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 51d9eebaba1..e553eb6c278 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -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. diff --git a/clang/test/CodeGen/builtin-memfns.c b/clang/test/CodeGen/builtin-memfns.c index 2ea67936547..fb4d7200752 100644 --- a/clang/test/CodeGen/builtin-memfns.c +++ b/clang/test/CodeGen/builtin-memfns.c @@ -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; +} |

