[cfe-commits] r51282 - in /cfe/trunk: lib/CodeGen/CGBuiltin.cpp test/CodeGen/builtinmemcpy.c
Eli Friedman
eli.friedman at gmail.com
Mon May 19 16:27:48 PDT 2008
Author: efriedma
Date: Mon May 19 18:27:48 2008
New Revision: 51282
URL: http://llvm.org/viewvc/llvm-project?rev=51282&view=rev
Log:
Implement CodeGen for __builtin_memcpy.
Added:
cfe/trunk/test/CodeGen/builtinmemcpy.c
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=51282&r1=51281&r2=51282&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon May 19 18:27:48 2008
@@ -252,6 +252,16 @@
return RValue::get(Builder.CreateAlloca(llvm::Type::Int8Ty,
EmitScalarExpr(E->getArg(0)),
"tmp"));
+ case Builtin::BI__builtin_memcpy: {
+ Value* MemCpyOps[4] = {
+ EmitScalarExpr(E->getArg(0)),
+ EmitScalarExpr(E->getArg(1)),
+ EmitScalarExpr(E->getArg(2)),
+ llvm::ConstantInt::get(llvm::Type::Int32Ty, 0)
+ };
+ Builder.CreateCall(CGM.getMemCpyFn(), MemCpyOps, MemCpyOps+4);
+ return RValue::get(MemCpyOps[0]);
+ }
case Builtin::BI__sync_fetch_and_add:
return EmitBinaryAtomic(*this, Intrinsic::atomic_las, E);
case Builtin::BI__sync_fetch_and_sub:
Added: cfe/trunk/test/CodeGen/builtinmemcpy.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtinmemcpy.c?rev=51282&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/builtinmemcpy.c (added)
+++ cfe/trunk/test/CodeGen/builtinmemcpy.c Mon May 19 18:27:48 2008
@@ -0,0 +1,3 @@
+// RUN: clang -emit-llvm < %s -o - | grep "llvm.memcpy"
+
+char* x(char* a, char* b) {return __builtin_memcpy(a, b, 4);}
More information about the cfe-commits
mailing list