Skip to content

Commit 81e4ca7

Browse files
committed
---
yaml --- r: 127770 b: refs/heads/master c: 0ad97c0 h: refs/heads/master v: v3
1 parent 26d92ce commit 81e4ca7

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 5aedcb1e916711bfeb65c26b5c6210a3fb5d72bf
2+
refs/heads/master: 0ad97c042a1ae41652a0157d0ac148e6e90db6c2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: aa98b25c4f0c10729dff37c699904ad57b8fbda8
55
refs/heads/try: d9c23fcbaea89871667272a67ecb8d3a512162f3

trunk/src/librustc/middle/trans/base.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ pub fn memcpy_ty(bcx: &Block, dst: ValueRef, src: ValueRef, t: ty::t) {
11221122
let llalign = llalign_of_min(ccx, llty);
11231123
call_memcpy(bcx, dst, src, llsz, llalign as u32);
11241124
} else {
1125-
Store(bcx, Load(bcx, src), dst);
1125+
store_ty(bcx, Load(bcx, src), dst, t);
11261126
}
11271127
}
11281128

@@ -1546,7 +1546,7 @@ pub fn build_return_block(fcx: &FunctionContext, ret_cx: &Block, retty: ty::t) {
15461546

15471547
let retslot = Load(ret_cx, fcx.llretslotptr.get().unwrap());
15481548
let retptr = Value(retslot);
1549-
let retval = match retptr.get_dominating_store(ret_cx) {
1549+
match retptr.get_dominating_store(ret_cx) {
15501550
// If there's only a single store to the ret slot, we can directly return
15511551
// the value that was stored and omit the store and the alloca
15521552
Some(s) => {
@@ -1557,21 +1557,28 @@ pub fn build_return_block(fcx: &FunctionContext, ret_cx: &Block, retty: ty::t) {
15571557
retptr.erase_from_parent();
15581558
}
15591559

1560-
if ty::type_is_bool(retty) {
1560+
let retval = if ty::type_is_bool(retty) {
15611561
Trunc(ret_cx, retval, Type::i1(fcx.ccx))
15621562
} else {
15631563
retval
1564+
};
1565+
1566+
if fcx.caller_expects_out_pointer {
1567+
store_ty(ret_cx, retval, get_param(fcx.llfn, 0), retty);
1568+
return RetVoid(ret_cx);
1569+
} else {
1570+
return Ret(ret_cx, retval);
1571+
}
1572+
}
1573+
// Otherwise, copy the return value to the ret slot
1574+
None => {
1575+
if fcx.caller_expects_out_pointer {
1576+
memcpy_ty(ret_cx, get_param(fcx.llfn, 0), retslot, retty);
1577+
return RetVoid(ret_cx);
1578+
} else {
1579+
return Ret(ret_cx, load_ty(ret_cx, retslot, retty));
15641580
}
15651581
}
1566-
// Otherwise, load the return value from the ret slot
1567-
None => load_ty(ret_cx, retslot, retty)
1568-
};
1569-
1570-
if fcx.caller_expects_out_pointer {
1571-
store_ty(ret_cx, retval, get_param(fcx.llfn, 0), retty);
1572-
RetVoid(ret_cx);
1573-
} else {
1574-
Ret(ret_cx, retval);
15751582
}
15761583
}
15771584

0 commit comments

Comments
 (0)