aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/IntrinsicLowering.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/IntrinsicLowering.cpp')
-rw-r--r--lib/CodeGen/IntrinsicLowering.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp
index 72a1d1485b..65835da4f0 100644
--- a/lib/CodeGen/IntrinsicLowering.cpp
+++ b/lib/CodeGen/IntrinsicLowering.cpp
@@ -77,13 +77,17 @@ void IntrinsicLowering::AddPrototypes(Module &M) {
break;
case Intrinsic::memcpy_i32:
case Intrinsic::memcpy_i64:
- EnsureFunctionExists(M, "memcpy", I->arg_begin(), --I->arg_end(),
- I->arg_begin()->getType());
+ M.getOrInsertFunction("memcpy", PointerType::get(Type::Int8Ty),
+ PointerType::get(Type::Int8Ty),
+ PointerType::get(Type::Int8Ty), Type::Int32Ty,
+ (Type *)0);
break;
case Intrinsic::memmove_i32:
case Intrinsic::memmove_i64:
- EnsureFunctionExists(M, "memmove", I->arg_begin(), --I->arg_end(),
- I->arg_begin()->getType());
+ M.getOrInsertFunction("memmove", PointerType::get(Type::Int8Ty),
+ PointerType::get(Type::Int8Ty),
+ PointerType::get(Type::Int8Ty), Type::Int32Ty,
+ (Type *)0);
break;
case Intrinsic::memset_i32:
case Intrinsic::memset_i64:
@@ -360,6 +364,9 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
}
case Intrinsic::memcpy_i64: {
static Constant *MemcpyFCache = 0;
+ Value * Size = cast<Value>(CI->op_end()-1);
+ if (Size->getType() != Type::Int32Ty)
+ Size->replaceAllUsesWith(new TruncInst(Size, Type::Int32Ty));
ReplaceCallWith("memcpy", CI, CI->op_begin()+1, CI->op_end()-1,
(*(CI->op_begin()+1))->getType(), MemcpyFCache);
break;