Skip to content

Commit 1b59a2b

Browse files
committed
---
yaml --- r: 64288 b: refs/heads/snap-stage3 c: 1d2e1a9 h: refs/heads/master v: v3
1 parent 7c9dcb5 commit 1b59a2b

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,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 5df2bb1bccd8394dbd73ffa52dea1151dcd0b0ad
4+
refs/heads/snap-stage3: 1d2e1a9ae5cc1affe54e3280cf272197a036beaf
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/trans/controlflow.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,8 @@ pub fn trans_if(bcx: block,
6767
expr::trans_to_datum(bcx, cond).to_result();
6868

6969
let then_bcx_in = scope_block(bcx, thn.info(), "then");
70-
let else_bcx_in = scope_block(bcx, els.info(), "else");
7170

7271
let cond_val = bool_to_i1(bcx, cond_val);
73-
CondBr(bcx, cond_val, then_bcx_in.llbb, else_bcx_in.llbb);
74-
75-
debug!("then_bcx_in=%s, else_bcx_in=%s",
76-
then_bcx_in.to_str(), else_bcx_in.to_str());
7772

7873
let then_bcx_out = trans_block(then_bcx_in, thn, dest);
7974
let then_bcx_out = trans_block_cleanups(then_bcx_out,
@@ -83,9 +78,10 @@ pub fn trans_if(bcx: block,
8378
// because trans_expr will create another scope block
8479
// context for the block, but we've already got the
8580
// 'else' context
86-
let else_bcx_out = match els {
81+
let (else_bcx_in, next_bcx) = match els {
8782
Some(elexpr) => {
88-
match elexpr.node {
83+
let else_bcx_in = scope_block(bcx, els.info(), "else");
84+
let else_bcx_out = match elexpr.node {
8985
ast::expr_if(_, _, _) => {
9086
let elseif_blk = ast_util::block_from_expr(elexpr);
9187
trans_block(else_bcx_in, &elseif_blk, dest)
@@ -95,14 +91,25 @@ pub fn trans_if(bcx: block,
9591
}
9692
// would be nice to have a constraint on ifs
9793
_ => bcx.tcx().sess.bug("strange alternative in if")
98-
}
94+
};
95+
let else_bcx_out = trans_block_cleanups(else_bcx_out,
96+
block_cleanups(else_bcx_in));
97+
98+
(else_bcx_in, join_blocks(bcx, [then_bcx_out, else_bcx_out]))
99+
}
100+
_ => {
101+
let next_bcx = sub_block(bcx, "next");
102+
Br(then_bcx_out, next_bcx.llbb);
103+
104+
(next_bcx, next_bcx)
99105
}
100-
_ => else_bcx_in
101106
};
102-
let else_bcx_out = trans_block_cleanups(else_bcx_out,
103-
block_cleanups(else_bcx_in));
104-
return join_blocks(bcx, [then_bcx_out, else_bcx_out]);
105107

108+
debug!("then_bcx_in=%s, else_bcx_in=%s",
109+
then_bcx_in.to_str(), else_bcx_in.to_str());
110+
111+
CondBr(bcx, cond_val, then_bcx_in.llbb, else_bcx_in.llbb);
112+
next_bcx
106113
}
107114

108115
pub fn join_blocks(parent_bcx: block, in_cxs: &[block]) -> block {

0 commit comments

Comments
 (0)