Skip to content

Commit 1959c95

Browse files
committed
---
yaml --- r: 225059 b: refs/heads/stable c: 3afd760 h: refs/heads/master i: 225057: 786afab 225055: 3ed1028 v: v3
1 parent 1527587 commit 1959c95

File tree

4 files changed

+14
-28
lines changed

4 files changed

+14
-28
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ refs/heads/tmp: e5d90d98402475b6e154ce216f9efcb80da1a747
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: 1fe32ca12c51afcd761d9962f51a74ff0d07a591
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 27d2bd13c357bed328735da8605fce1416acc060
32+
refs/heads/stable: 3afd760bb3fc8c90adfd9451e1cd8b161301f218
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,8 +869,7 @@ pub fn with_cond<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
869869
{
870870
let _icx = push_ctxt("with_cond");
871871

872-
if bcx.unreachable.get() ||
873-
(common::is_const(val) && common::const_to_uint(val) == 0) {
872+
if bcx.unreachable.get() || common::const_to_opt_uint(val) == Some(0) {
874873
return bcx;
875874
}
876875

branches/stable/src/librustc_trans/trans/common.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -919,12 +919,6 @@ pub fn const_get_elt(cx: &CrateContext, v: ValueRef, us: &[c_uint])
919919
}
920920
}
921921

922-
pub fn is_const(v: ValueRef) -> bool {
923-
unsafe {
924-
llvm::LLVMIsConstant(v) == True
925-
}
926-
}
927-
928922
pub fn const_to_int(v: ValueRef) -> i64 {
929923
unsafe {
930924
llvm::LLVMConstIntGetSExtValue(v)

branches/stable/src/librustc_trans/trans/controlflow.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -166,31 +166,24 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
166166
let cond_val = unpack_result!(bcx, expr::trans(bcx, cond).to_llbool());
167167

168168
// Drop branches that are known to be impossible
169-
if is_const(cond_val) && !is_undef(cond_val) {
170-
if const_to_uint(cond_val) == 1 {
171-
match els {
172-
Some(elexpr) => {
173-
let mut trans = TransItemVisitor { ccx: bcx.fcx.ccx };
174-
trans.visit_expr(&*elexpr);
175-
}
176-
None => {}
177-
}
169+
if let Some(cv) = const_to_opt_uint(cond_val) {
170+
if cv == 1 {
178171
// if true { .. } [else { .. }]
179172
bcx = trans_block(bcx, &*thn, dest);
180173
trans::debuginfo::clear_source_location(bcx.fcx);
174+
175+
if let Some(elexpr) = els {
176+
let mut trans = TransItemVisitor { ccx: bcx.fcx.ccx };
177+
trans.visit_expr(&*elexpr);
178+
}
181179
} else {
182-
let mut trans = TransItemVisitor { ccx: bcx.fcx.ccx } ;
180+
// if false { .. } [else { .. }]
181+
let mut trans = TransItemVisitor { ccx: bcx.fcx.ccx };
183182
trans.visit_block(&*thn);
184183

185-
match els {
186-
// if false { .. } else { .. }
187-
Some(elexpr) => {
188-
bcx = expr::trans_into(bcx, &*elexpr, dest);
189-
trans::debuginfo::clear_source_location(bcx.fcx);
190-
}
191-
192-
// if false { .. }
193-
None => { }
184+
if let Some(elexpr) = els {
185+
bcx = expr::trans_into(bcx, &*elexpr, dest);
186+
trans::debuginfo::clear_source_location(bcx.fcx);
194187
}
195188
}
196189

0 commit comments

Comments
 (0)