Skip to content

Commit 818ffea

Browse files
committed
---
yaml --- r: 214523 b: refs/heads/beta c: 3afd760 h: refs/heads/master i: 214521: 247f6af 214519: 7d1e2e1 v: v3
1 parent ab2eaa8 commit 818ffea

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
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 27d2bd13c357bed328735da8605fce1416acc060
26+
refs/heads/beta: 3afd760bb3fc8c90adfd9451e1cd8b161301f218
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 8c0aa6d64ebab528f7eb182812007155d6044972
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

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