Skip to content

Commit a95dbde

Browse files
committed
Cast memcpy args to correct types.
1 parent 9b3182a commit a95dbde

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/comp/middle/trans.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,10 @@ fn build_memcpy(@block_ctxt cx,
637637
auto memcpy = cx.fcx.ccx.intrinsics.get("llvm.memcpy");
638638
auto src_ptr = cx.build.PointerCast(src, T_ptr(T_i8()));
639639
auto dst_ptr = cx.build.PointerCast(dst, T_ptr(T_i8()));
640-
auto size = lib.llvm.llvm.LLVMSizeOf(llty);
641-
auto align = lib.llvm.llvm.LLVMAlignOf(llty);
640+
auto size = cx.build.IntCast(lib.llvm.llvm.LLVMSizeOf(llty),
641+
T_i32());
642+
auto align = cx.build.IntCast(lib.llvm.llvm.LLVMAlignOf(llty),
643+
T_i32());
642644
auto volatile = C_integral(0, T_i1());
643645
ret res(cx, cx.build.Call(memcpy,
644646
vec(dst_ptr, src_ptr,
@@ -1670,7 +1672,9 @@ fn declare_intrinsics(ModuleRef llmod) -> hashmap[str,ValueRef] {
16701672
// FIXME: switch this to 64-bit memcpy when targeting a 64-bit system.
16711673
let vec[TypeRef] T_memcpy_args = vec(T_ptr(T_i8()),
16721674
T_ptr(T_i8()),
1673-
T_i32(), T_i32(), T_i1());
1675+
T_i32(),
1676+
T_i32(),
1677+
T_i1());
16741678
auto trap = decl_cdecl_fn(llmod, "llvm.trap",
16751679
T_fn(T_trap_args, T_void()));
16761680
auto memcpy = decl_cdecl_fn(llmod, "llvm.memcpy",

0 commit comments

Comments
 (0)