Skip to content

Commit 60813bd

Browse files
committed
---
yaml --- r: 207357 b: refs/heads/auto c: 3afd760 h: refs/heads/master i: 207355: b160a21 v: v3
1 parent 9802ddc commit 60813bd

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
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 27d2bd13c357bed328735da8605fce1416acc060
13+
refs/heads/auto: 3afd760bb3fc8c90adfd9451e1cd8b161301f218
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/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/auto/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/auto/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)