aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/IntrinsicLowering.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-12 17:01:09 +0000
committerChris Lattner <sabre@nondot.org>2004-02-12 17:01:09 +0000
commit5fe51cc2c46afca64638597cdef3bdafa6cd0a8c (patch)
tree68f795da62197fb9a13fb3340a315ae789104074 /lib/CodeGen/IntrinsicLowering.cpp
parent2a90ba60175f93e7438165d8423100aa573c16c5 (diff)
Implement the llvm.memcpy intrinsic
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/IntrinsicLowering.cpp')
-rw-r--r--lib/CodeGen/IntrinsicLowering.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp
index 026150f78b..48ae01540b 100644
--- a/lib/CodeGen/IntrinsicLowering.cpp
+++ b/lib/CodeGen/IntrinsicLowering.cpp
@@ -13,8 +13,8 @@
#include "llvm/IntrinsicLowering.h"
#include "llvm/Constant.h"
+#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
-#include "llvm/Type.h"
#include "llvm/iOther.h"
using namespace llvm;
@@ -57,6 +57,20 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
if (CI->getType() != Type::VoidTy)
CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
break; // Simply strip out debugging intrinsics
+
+ case Intrinsic::memcpy: {
+ // The memcpy intrinsic take an extra alignment argument that the memcpy
+ // libc function does not.
+ const FunctionType *CFT = Callee->getFunctionType();
+ FunctionType *FT =
+ FunctionType::get(*CFT->param_begin(),
+ std::vector<const Type*>(CFT->param_begin(), CFT->param_end()-1),
+ false);
+ Function *MemCpy = M->getOrInsertFunction("memcpy", FT);
+ new CallInst(MemCpy, std::vector<Value*>(CI->op_begin()+1, CI->op_end()-1),
+ CI->getName(), CI);
+ break;
+ }
}
assert(CI->use_empty() &&