Skip to content

Commit ca97ccd

Browse files
committed
---
yaml --- r: 273271 b: refs/heads/beta c: 38638d3 h: refs/heads/master i: 273269: 7e2cc40 273267: 3edcfed 273263: 19135c0
1 parent ca29a70 commit ca97ccd

File tree

5 files changed

+39
-36
lines changed

5 files changed

+39
-36
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: b63a5eed6e8a2379aabe4eb0328ad238c057c60f
26+
refs/heads/beta: 38638d37f70667d8ac5ea6e5cc47e0e04f94d247
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc_trans/trans/abi.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
use llvm::{self, ValueRef};
1212
use trans::base;
13-
use trans::build::*;
13+
use trans::build::B;
14+
use trans::builder::Builder;
1415
use trans::common::{type_is_fat_ptr, Block};
1516
use trans::context::CrateContext;
1617
use trans::cabi_x86;
@@ -145,27 +146,26 @@ impl ArgType {
145146
/// lvalue for the original Rust type of this argument/return.
146147
/// Can be used for both storing formal arguments into Rust variables
147148
/// or results of call/invoke instructions into their destinations.
148-
pub fn store(&self, bcx: Block, mut val: ValueRef, dst: ValueRef) {
149+
pub fn store(&self, b: &Builder, mut val: ValueRef, dst: ValueRef) {
149150
if self.is_ignore() {
150151
return;
151152
}
152153
if self.is_indirect() {
153-
let llsz = llsize_of(bcx.ccx(), self.ty);
154-
let llalign = llalign_of_min(bcx.ccx(), self.ty);
155-
base::call_memcpy(bcx, dst, val, llsz, llalign as u32);
154+
let llsz = llsize_of(b.ccx, self.ty);
155+
let llalign = llalign_of_min(b.ccx, self.ty);
156+
base::call_memcpy(b, dst, val, llsz, llalign as u32);
156157
} else if let Some(ty) = self.cast {
157-
let store = Store(bcx, val, PointerCast(bcx, dst, ty.ptr_to()));
158-
let llalign = llalign_of_min(bcx.ccx(), self.ty);
159-
if !bcx.unreachable.get() {
160-
unsafe {
161-
llvm::LLVMSetAlignment(store, llalign);
162-
}
158+
let cast_dst = b.pointercast(dst, ty.ptr_to());
159+
let store = b.store(val, cast_dst);
160+
let llalign = llalign_of_min(b.ccx, self.ty);
161+
unsafe {
162+
llvm::LLVMSetAlignment(store, llalign);
163163
}
164164
} else {
165-
if self.original_ty == Type::i1(bcx.ccx()) {
166-
val = ZExt(bcx, val, Type::i8(bcx.ccx()));
165+
if self.original_ty == Type::i1(b.ccx) {
166+
val = b.zext(val, Type::i8(b.ccx));
167167
}
168-
Store(bcx, val, dst);
168+
b.store(val, dst);
169169
}
170170
}
171171

@@ -178,7 +178,9 @@ impl ArgType {
178178
}
179179
let val = llvm::get_param(bcx.fcx.llfn, *idx as c_uint);
180180
*idx += 1;
181-
self.store(bcx, val, dst);
181+
if !bcx.unreachable.get() {
182+
self.store(&B(bcx), val, dst);
183+
}
182184
}
183185
}
184186

branches/beta/src/librustc_trans/trans/base.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,37 +1096,37 @@ pub fn trans_unwind_resume(bcx: Block, lpval: ValueRef) {
10961096
}
10971097
}
10981098

1099-
1100-
pub fn call_memcpy(cx: Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, align: u32) {
1099+
pub fn call_memcpy<'bcx, 'tcx>(b: &Builder<'bcx, 'tcx>,
1100+
dst: ValueRef,
1101+
src: ValueRef,
1102+
n_bytes: ValueRef,
1103+
align: u32) {
11011104
let _icx = push_ctxt("call_memcpy");
1102-
let ccx = cx.ccx();
1105+
let ccx = b.ccx;
11031106
let ptr_width = &ccx.sess().target.target.target_pointer_width[..];
11041107
let key = format!("llvm.memcpy.p0i8.p0i8.i{}", ptr_width);
11051108
let memcpy = ccx.get_intrinsic(&key);
1106-
let src_ptr = PointerCast(cx, src, Type::i8p(ccx));
1107-
let dst_ptr = PointerCast(cx, dst, Type::i8p(ccx));
1108-
let size = IntCast(cx, n_bytes, ccx.int_type());
1109+
let src_ptr = b.pointercast(src, Type::i8p(ccx));
1110+
let dst_ptr = b.pointercast(dst, Type::i8p(ccx));
1111+
let size = b.intcast(n_bytes, ccx.int_type());
11091112
let align = C_i32(ccx, align as i32);
11101113
let volatile = C_bool(ccx, false);
1111-
Call(cx,
1112-
memcpy,
1113-
&[dst_ptr, src_ptr, size, align, volatile],
1114-
DebugLoc::None);
1114+
b.call(memcpy, &[dst_ptr, src_ptr, size, align, volatile], None);
11151115
}
11161116

11171117
pub fn memcpy_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, dst: ValueRef, src: ValueRef, t: Ty<'tcx>) {
11181118
let _icx = push_ctxt("memcpy_ty");
11191119
let ccx = bcx.ccx();
11201120

1121-
if type_is_zero_size(ccx, t) {
1121+
if type_is_zero_size(ccx, t) || bcx.unreachable.get() {
11221122
return;
11231123
}
11241124

11251125
if t.is_structural() {
11261126
let llty = type_of::type_of(ccx, t);
11271127
let llsz = llsize_of(ccx, llty);
11281128
let llalign = type_of::align_of(ccx, t);
1129-
call_memcpy(bcx, dst, src, llsz, llalign as u32);
1129+
call_memcpy(&B(bcx), dst, src, llsz, llalign as u32);
11301130
} else if common::type_is_fat_ptr(bcx.tcx(), t) {
11311131
let (data, extra) = load_fat_ptr(bcx, src, t);
11321132
store_fat_ptr(bcx, data, extra, dst, t);
@@ -1746,7 +1746,7 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
17461746
assert_eq!(cast_ty, None);
17471747
let llsz = llsize_of(self.ccx, self.fn_ty.ret.ty);
17481748
let llalign = llalign_of_min(self.ccx, self.fn_ty.ret.ty);
1749-
call_memcpy(ret_cx, get_param(self.llfn, 0),
1749+
call_memcpy(&B(ret_cx), get_param(self.llfn, 0),
17501750
retslot, llsz, llalign as u32);
17511751
RetVoid(ret_cx, ret_debug_location)
17521752
}

branches/beta/src/librustc_trans/trans/callee.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,11 @@ fn trans_call_inner<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
739739
let llrust_align = llalign_of_min(ccx, llrust_ret_ty);
740740
let llalign = cmp::min(llforeign_align, llrust_align);
741741
debug!("llrust_size={}", llrust_size);
742-
base::call_memcpy(bcx, llretptr_i8, llscratch_i8,
743-
C_uint(ccx, llrust_size), llalign as u32);
742+
743+
if !bcx.unreachable.get() {
744+
base::call_memcpy(&B(bcx), llretptr_i8, llscratch_i8,
745+
C_uint(ccx, llrust_size), llalign as u32);
746+
}
744747
base::call_lifetime_end(bcx, llscratch);
745748
} else if let Some(llretslot) = opt_llretslot {
746749
base::store_ty(bcx, llret, llretslot, output.unwrap());

branches/beta/src/librustc_trans/trans/tvec.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,9 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
174174
let bytes = s.len();
175175
let llbytes = C_uint(bcx.ccx(), bytes);
176176
let llcstr = C_cstr(bcx.ccx(), (*s).clone(), false);
177-
base::call_memcpy(bcx,
178-
lldest,
179-
llcstr,
180-
llbytes,
181-
1);
177+
if !bcx.unreachable.get() {
178+
base::call_memcpy(&B(bcx), lldest, llcstr, llbytes, 1);
179+
}
182180
return bcx;
183181
}
184182
}

0 commit comments

Comments
 (0)