Skip to content

Commit 54d66c0

Browse files
committed
---
yaml --- r: 3455 b: refs/heads/master c: bbd0d58 h: refs/heads/master i: 3453: 67ba269 3451: 978f6b2 3447: 1b3fe86 3439: 522c580 3423: fafd452 3391: f256c57 3327: fae2cb5 v: v3
1 parent bf565fb commit 54d66c0

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 47b3e087e945a2a8fcfd1179e333746d294c1259
2+
refs/heads/master: bbd0d589550b11a3267c9e52608813f54bf3b89a

trunk/src/comp/middle/trans.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3180,14 +3180,21 @@ fn copy_val(&@block_ctxt cx, copy_action action, ValueRef dst, ValueRef src,
31803180
ret rslt(bcx, bcx.build.Store(src, dst));
31813181
} else if (ty::type_is_structural(ccx.tcx, t) ||
31823182
ty::type_has_dynamic_size(ccx.tcx, t)) {
3183-
auto bcx;
3183+
// Check for self-assignment.
3184+
auto do_copy_cx = new_sub_block_ctxt(cx, "do_copy");
3185+
auto next_cx = new_sub_block_ctxt(cx, "next");
3186+
auto self_assigning = cx.build.ICmp(lib::llvm::LLVMIntNE,
3187+
cx.build.PointerCast(dst, val_ty(src)), src);
3188+
cx.build.CondBr(self_assigning, do_copy_cx.llbb, next_cx.llbb);
3189+
31843190
if (action == DROP_EXISTING) {
3185-
bcx = drop_ty(cx, dst, t).bcx;
3186-
} else {
3187-
bcx = cx;
3191+
do_copy_cx = drop_ty(do_copy_cx, dst, t).bcx;
31883192
}
3189-
bcx = memmove_ty(bcx, dst, src, t).bcx;
3190-
ret copy_ty(bcx, dst, t);
3193+
do_copy_cx = memmove_ty(do_copy_cx, dst, src, t).bcx;
3194+
do_copy_cx = copy_ty(do_copy_cx, dst, t).bcx;
3195+
do_copy_cx.build.Br(next_cx.llbb);
3196+
3197+
ret rslt(next_cx, C_nil());
31913198
}
31923199
ccx.sess.bug("unexpected type in trans::copy_val: " +
31933200
ty_to_str(ccx.tcx, t));

0 commit comments

Comments
 (0)