Skip to content

Commit 73cdc5f

Browse files
committed
---
yaml --- r: 275154 b: refs/heads/stable c: 281f9d8 h: refs/heads/master
1 parent 121f441 commit 73cdc5f

File tree

17 files changed

+332
-117
lines changed

17 files changed

+332
-117
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 71f29cd83704b39a2aefd609eab645decd3bce92
32+
refs/heads/stable: 281f9d868fee8e4f9750fc12289dc10522f587ea
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/mk/cfg/armv7-unknown-linux-gnueabihf.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ CFG_UNIXY_armv7-unknown-linux-gnueabihf := 1
2121
CFG_LDPATH_armv7-unknown-linux-gnueabihf :=
2222
CFG_RUN_armv7-unknown-linux-gnueabihf=$(2)
2323
CFG_RUN_TARG_armv7-unknown-linux-gnueabihf=$(call CFG_RUN_armv7-unknown-linux-gnueabihf,,$(2))
24-
RUSTC_FLAGS_armv7-unknown-linux-gnueabihf := -C target-feature=+v7,+vfp2,+neon
24+
RUSTC_FLAGS_armv7-unknown-linux-gnueabihf :=
2525
RUSTC_CROSS_FLAGS_armv7-unknown-linux-gnueabihf :=
2626
CFG_GNU_TRIPLE_armv7-unknown-linux-gnueabihf := armv7-unknown-linux-gnueabihf

branches/stable/src/librustc_back/target/armv7_unknown_linux_gnueabihf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn target() -> Target {
2222
target_vendor: "unknown".to_string(),
2323

2424
options: TargetOptions {
25-
features: "+v7,+vfp2,+neon".to_string(),
25+
features: "+v7,+vfp3,+neon".to_string(),
2626
cpu: "cortex-a8".to_string(),
2727
.. base
2828
}

branches/stable/src/librustc_data_structures/bitvec.rs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,45 @@ impl BitVector {
5050
let extra_words = self.data.len() - num_words;
5151
self.data.extend((0..extra_words).map(|_| 0));
5252
}
53+
54+
/// Iterates over indexes of set bits in a sorted order
55+
pub fn iter<'a>(&'a self) -> BitVectorIter<'a> {
56+
BitVectorIter {
57+
iter: self.data.iter(),
58+
current: 0,
59+
idx: 0
60+
}
61+
}
62+
}
63+
64+
pub struct BitVectorIter<'a> {
65+
iter: ::std::slice::Iter<'a, u64>,
66+
current: u64,
67+
idx: usize
68+
}
69+
70+
impl<'a> Iterator for BitVectorIter<'a> {
71+
type Item = usize;
72+
fn next(&mut self) -> Option<usize> {
73+
while self.current == 0 {
74+
self.current = if let Some(&i) = self.iter.next() {
75+
if i == 0 {
76+
self.idx += 64;
77+
continue;
78+
} else {
79+
self.idx = u64s(self.idx) * 64;
80+
i
81+
}
82+
} else {
83+
return None;
84+
}
85+
}
86+
let offset = self.current.trailing_zeros() as usize;
87+
self.current >>= offset;
88+
self.current >>= 1; // shift otherwise overflows for 0b1000_0000_…_0000
89+
self.idx += offset + 1;
90+
return Some(self.idx - 1);
91+
}
5392
}
5493

5594
/// A "bit matrix" is basically a square matrix of booleans
@@ -153,6 +192,46 @@ fn word_mask(index: usize) -> (usize, u64) {
153192
(word, mask)
154193
}
155194

195+
#[test]
196+
fn bitvec_iter_works() {
197+
let mut bitvec = BitVector::new(100);
198+
bitvec.insert(1);
199+
bitvec.insert(10);
200+
bitvec.insert(19);
201+
bitvec.insert(62);
202+
bitvec.insert(63);
203+
bitvec.insert(64);
204+
bitvec.insert(65);
205+
bitvec.insert(66);
206+
bitvec.insert(99);
207+
assert_eq!(bitvec.iter().collect::<Vec<_>>(), [1, 10, 19, 62, 63, 64, 65, 66, 99]);
208+
}
209+
210+
#[test]
211+
fn bitvec_iter_works_2() {
212+
let mut bitvec = BitVector::new(300);
213+
bitvec.insert(1);
214+
bitvec.insert(10);
215+
bitvec.insert(19);
216+
bitvec.insert(62);
217+
bitvec.insert(66);
218+
bitvec.insert(99);
219+
bitvec.insert(299);
220+
assert_eq!(bitvec.iter().collect::<Vec<_>>(), [1, 10, 19, 62, 66, 99, 299]);
221+
222+
}
223+
224+
#[test]
225+
fn bitvec_iter_works_3() {
226+
let mut bitvec = BitVector::new(319);
227+
bitvec.insert(0);
228+
bitvec.insert(127);
229+
bitvec.insert(191);
230+
bitvec.insert(255);
231+
bitvec.insert(319);
232+
assert_eq!(bitvec.iter().collect::<Vec<_>>(), [0, 127, 191, 255, 319]);
233+
}
234+
156235
#[test]
157236
fn union_two_vecs() {
158237
let mut vec1 = BitVector::new(65);

branches/stable/src/librustc_mir/transform/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ pub mod simplify_cfg;
1313
pub mod erase_regions;
1414
pub mod no_landing_pads;
1515
pub mod type_check;
16-
mod util;

branches/stable/src/librustc_mir/transform/simplify_cfg.rs

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use rustc_data_structures::bitvec::BitVector;
1112
use rustc::middle::const_eval::ConstVal;
1213
use rustc::middle::infer;
1314
use rustc::mir::repr::*;
14-
use transform::util;
1515
use rustc::mir::transform::MirPass;
1616

1717
pub struct SimplifyCfg;
@@ -22,23 +22,21 @@ impl SimplifyCfg {
2222
}
2323

2424
fn remove_dead_blocks(&self, mir: &mut Mir) {
25-
let mut seen = vec![false; mir.basic_blocks.len()];
26-
25+
let mut seen = BitVector::new(mir.basic_blocks.len());
2726
// These blocks are always required.
28-
seen[START_BLOCK.index()] = true;
29-
seen[END_BLOCK.index()] = true;
27+
seen.insert(START_BLOCK.index());
28+
seen.insert(END_BLOCK.index());
3029

31-
let mut worklist = vec![START_BLOCK];
30+
let mut worklist = Vec::with_capacity(4);
31+
worklist.push(START_BLOCK);
3232
while let Some(bb) = worklist.pop() {
3333
for succ in mir.basic_block_data(bb).terminator().successors().iter() {
34-
if !seen[succ.index()] {
35-
seen[succ.index()] = true;
34+
if seen.insert(succ.index()) {
3635
worklist.push(*succ);
3736
}
3837
}
3938
}
40-
41-
util::retain_basic_blocks(mir, &seen);
39+
retain_basic_blocks(mir, &seen);
4240
}
4341

4442
fn remove_goto_chains(&self, mir: &mut Mir) -> bool {
@@ -90,12 +88,12 @@ impl SimplifyCfg {
9088
for bb in mir.all_basic_blocks() {
9189
let basic_block = mir.basic_block_data_mut(bb);
9290
let mut terminator = basic_block.terminator_mut();
93-
9491
*terminator = match *terminator {
9592
Terminator::If { ref targets, .. } if targets.0 == targets.1 => {
9693
changed = true;
9794
Terminator::Goto { target: targets.0 }
9895
}
96+
9997
Terminator::If { ref targets, cond: Operand::Constant(Constant {
10098
literal: Literal::Value {
10199
value: ConstVal::Bool(cond)
@@ -108,6 +106,7 @@ impl SimplifyCfg {
108106
Terminator::Goto { target: targets.1 }
109107
}
110108
}
109+
111110
Terminator::SwitchInt { ref targets, .. } if targets.len() == 1 => {
112111
Terminator::Goto { target: targets[0] }
113112
}
@@ -131,3 +130,27 @@ impl MirPass for SimplifyCfg {
131130
mir.basic_blocks.shrink_to_fit();
132131
}
133132
}
133+
134+
/// Mass removal of basic blocks to keep the ID-remapping cheap.
135+
fn retain_basic_blocks(mir: &mut Mir, keep: &BitVector) {
136+
let num_blocks = mir.basic_blocks.len();
137+
138+
let mut replacements: Vec<_> = (0..num_blocks).map(BasicBlock::new).collect();
139+
let mut used_blocks = 0;
140+
for alive_index in keep.iter() {
141+
replacements[alive_index] = BasicBlock::new(used_blocks);
142+
if alive_index != used_blocks {
143+
// Swap the next alive block data with the current available slot. Since alive_index is
144+
// non-decreasing this is a valid operation.
145+
mir.basic_blocks.swap(alive_index, used_blocks);
146+
}
147+
used_blocks += 1;
148+
}
149+
mir.basic_blocks.truncate(used_blocks);
150+
151+
for bb in mir.all_basic_blocks() {
152+
for target in mir.basic_block_data_mut(bb).terminator_mut().successors_mut() {
153+
*target = replacements[target.index()];
154+
}
155+
}
156+
}

branches/stable/src/librustc_mir/transform/util.rs

Lines changed: 0 additions & 51 deletions
This file was deleted.

branches/stable/src/libstd/ffi/os_str.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,44 @@ impl Ord for OsStr {
411411
fn cmp(&self, other: &OsStr) -> cmp::Ordering { self.bytes().cmp(other.bytes()) }
412412
}
413413

414+
macro_rules! impl_cmp {
415+
($lhs:ty, $rhs: ty) => {
416+
#[stable(feature = "cmp_os_str", since = "1.8.0")]
417+
impl<'a, 'b> PartialEq<$rhs> for $lhs {
418+
#[inline]
419+
fn eq(&self, other: &$rhs) -> bool { <OsStr as PartialEq>::eq(self, other) }
420+
}
421+
422+
#[stable(feature = "cmp_os_str", since = "1.8.0")]
423+
impl<'a, 'b> PartialEq<$lhs> for $rhs {
424+
#[inline]
425+
fn eq(&self, other: &$lhs) -> bool { <OsStr as PartialEq>::eq(self, other) }
426+
}
427+
428+
#[stable(feature = "cmp_os_str", since = "1.8.0")]
429+
impl<'a, 'b> PartialOrd<$rhs> for $lhs {
430+
#[inline]
431+
fn partial_cmp(&self, other: &$rhs) -> Option<cmp::Ordering> {
432+
<OsStr as PartialOrd>::partial_cmp(self, other)
433+
}
434+
}
435+
436+
#[stable(feature = "cmp_os_str", since = "1.8.0")]
437+
impl<'a, 'b> PartialOrd<$lhs> for $rhs {
438+
#[inline]
439+
fn partial_cmp(&self, other: &$lhs) -> Option<cmp::Ordering> {
440+
<OsStr as PartialOrd>::partial_cmp(self, other)
441+
}
442+
}
443+
}
444+
}
445+
446+
impl_cmp!(OsString, OsStr);
447+
impl_cmp!(OsString, &'a OsStr);
448+
impl_cmp!(Cow<'a, OsStr>, OsStr);
449+
impl_cmp!(Cow<'a, OsStr>, &'b OsStr);
450+
impl_cmp!(Cow<'a, OsStr>, OsString);
451+
414452
#[stable(feature = "rust1", since = "1.0.0")]
415453
impl Hash for OsStr {
416454
#[inline]

0 commit comments

Comments
 (0)