diff options
| author | James Miller <james@aatch.net> | 2015-01-17 17:04:15 +1300 |
|---|---|---|
| committer | James Miller <james@aatch.net> | 2015-01-19 09:21:23 +1300 |
| commit | 0859e5ebb319ceddcce01ddb63470d8f59860aba (patch) | |
| tree | 856cc6c06996da5701272442f691244245bd60b1 | |
| parent | dcaeb6aa23ecba2dc2af870668a9239136d20fa3 (diff) | |
| download | rust-0859e5ebb319ceddcce01ddb63470d8f59860aba.tar.gz rust-0859e5ebb319ceddcce01ddb63470d8f59860aba.zip | |
Use `zero_mem` instead of a zerointializer for `init` intrinsic
LLVM gets overwhelmed when presented with a zeroinitializer for a large type. In unoptimised builds, it generates a long sequence of stores to memory. In optmised builds, it manages to generate a standard memset of zero values, but takes a long time doing so. Call out to the `llvm.memset` function to zero out the memory instead.
| -rw-r--r-- | src/librustc_trans/trans/intrinsic.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/librustc_trans/trans/intrinsic.rs b/src/librustc_trans/trans/intrinsic.rs index 91c7409182d..eaf9b4a6bf7 100644 --- a/src/librustc_trans/trans/intrinsic.rs +++ b/src/librustc_trans/trans/intrinsic.rs @@ -361,12 +361,11 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, } (_, "init") => { let tp_ty = *substs.types.get(FnSpace, 0); - let lltp_ty = type_of::arg_type_of(ccx, tp_ty); - if return_type_is_void(ccx, tp_ty) { - C_nil(ccx) - } else { - C_null(lltp_ty) + if !return_type_is_void(ccx, tp_ty) { + // Just zero out the stack slot + zero_mem(bcx, llresult, tp_ty); } + C_nil(ccx) } // Effectively no-ops (_, "uninit") | (_, "forget") => { |
