From 877f001512b2ce16d86d5d4cf16d81e509294d79 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sat, 18 Jun 2011 16:59:44 -0700 Subject: [PATCH] rustc: Don't bother to supply an alignment argument to the memmove intrinsic; LLVM is very fussy about what it considers a constant. --- src/comp/middle/trans.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index e37717dc1fe1..eb1e1fd6a567 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -2922,9 +2922,12 @@ fn free_ty(&@block_ctxt cx, ValueRef v, ty::t t) -> result { ret res(cx, C_nil()); } -fn call_memmove(&@block_ctxt cx, ValueRef dst, ValueRef src, ValueRef n_bytes, - ValueRef align_bytes) -> result { +fn call_memmove(&@block_ctxt cx, ValueRef dst, ValueRef src, + ValueRef n_bytes) -> result { // FIXME: switch to the 64-bit variant when on such a platform. + // TODO: Provide LLVM with better alignment information when the alignment + // is statically known (it must be nothing more than a constant int, or + // LLVM complains -- not even a constant element of a tydesc works). auto i = cx.fcx.lcx.ccx.intrinsics; assert (i.contains_key("llvm.memmove.p0i8.p0i8.i32")); @@ -2932,10 +2935,7 @@ fn call_memmove(&@block_ctxt cx, ValueRef dst, ValueRef src, ValueRef n_bytes, auto src_ptr = cx.build.PointerCast(src, T_ptr(T_i8())); auto dst_ptr = cx.build.PointerCast(dst, T_ptr(T_i8())); auto size = cx.build.IntCast(n_bytes, T_i32()); - auto align = - if (lib::llvm::llvm::LLVMIsConstant(align_bytes) == True) { - cx.build.IntCast(align_bytes, T_i32()) - } else { cx.build.IntCast(C_int(0), T_i32()) }; + auto align = C_int(0); auto volatile = C_bool(false); ret res(cx, cx.build.Call(memmove, @@ -2965,8 +2965,7 @@ fn memmove_ty(&@block_ctxt cx, ValueRef dst, ValueRef src, &ty::t t) -> result { if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) { auto llsz = size_of(cx, t); - auto llalign = align_of(llsz.bcx, t); - ret call_memmove(llalign.bcx, dst, src, llsz.val, llalign.val); + ret call_memmove(llsz.bcx, dst, src, llsz.val); } else { ret res(cx, cx.build.Store(cx.build.Load(src), dst)); } } @@ -3825,8 +3824,7 @@ mod ivec { on_heap_cx = rslt.bcx; auto new_heap_ptr = rslt.val; - rslt = call_memmove(on_heap_cx, new_heap_ptr, heap_ptr, heap_part_sz, - C_int(4)); // FIXME: align + rslt = call_memmove(on_heap_cx, new_heap_ptr, heap_ptr, heap_part_sz); on_heap_cx = rslt.bcx; on_heap_cx.build.Store(new_heap_ptr, heap_ptr_ptr);