Skip to content

Commit 4aa13ab

Browse files
committed
---
yaml --- r: 272246 b: refs/heads/auto c: 605bc04 h: refs/heads/master
1 parent c5f2467 commit 4aa13ab

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 63321ca19390535795780ce15991b6238fb67db4
11+
refs/heads/auto: 605bc042646ef0dc0bd6e0420e6bd5a4715c93df
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/librustc_data_structures/bitvec.rs

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

11+
use std::iter::FromIterator;
12+
1113
/// A very simple BitVector type.
1214
#[derive(Clone)]
1315
pub struct BitVector {
@@ -51,7 +53,9 @@ impl BitVector {
5153
pub fn grow(&mut self, num_bits: usize) {
5254
let num_words = u64s(num_bits);
5355
let extra_words = self.data.len() - num_words;
54-
self.data.extend((0..extra_words).map(|_| 0));
56+
if extra_words > 0 {
57+
self.data.extend((0..extra_words).map(|_| 0));
58+
}
5559
}
5660

5761
/// Iterates over indexes of set bits in a sorted order
@@ -94,6 +98,27 @@ impl<'a> Iterator for BitVectorIter<'a> {
9498
}
9599
}
96100

101+
impl FromIterator<bool> for BitVector {
102+
fn from_iter<I>(iter: I) -> BitVector where I: IntoIterator<Item=bool> {
103+
let iter = iter.into_iter();
104+
let (len, _) = iter.size_hint();
105+
// Make the minimum length for the bitvector 64 bits since that's
106+
// the smallest non-zero size anyway.
107+
let len = if len < 64 { 64 } else { len };
108+
let mut bv = BitVector::new(len);
109+
for (idx, val) in iter.enumerate() {
110+
if idx > len {
111+
bv.grow(idx);
112+
}
113+
if val {
114+
bv.insert(idx);
115+
}
116+
}
117+
118+
bv
119+
}
120+
}
121+
97122
/// A "bit matrix" is basically a square matrix of booleans
98123
/// represented as one gigantic bitvector. In other words, it is as if
99124
/// you have N bitvectors, each of length N. Note that `elements` here is `N`/

branches/auto/src/librustc_mir/transform/break_critical_edges.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ use rustc::mir::repr::*;
1313
use rustc::mir::transform::{MirPass, Pass};
1414
use syntax::ast::NodeId;
1515

16+
use rustc_data_structures::bitvec::BitVector;
17+
1618
use traversal;
1719

1820
pub struct BreakCriticalEdges;
@@ -60,6 +62,9 @@ fn break_critical_edges(mir: &mut Mir) {
6062
}
6163
}
6264

65+
let cleanup_map : BitVector = mir.basic_blocks
66+
.iter().map(|bb| bb.is_cleanup).collect();
67+
6368
// We need a place to store the new blocks generated
6469
let mut new_blocks = Vec::new();
6570

@@ -84,7 +89,9 @@ fn break_critical_edges(mir: &mut Mir) {
8489
scope: term_scope,
8590
kind: TerminatorKind::Goto { target: *tgt }
8691
};
87-
let data = BasicBlockData::new(Some(goto));
92+
let mut data = BasicBlockData::new(Some(goto));
93+
data.is_cleanup = cleanup_map.contains(tgt.index());
94+
8895
// Get the index it will be when inserted into the MIR
8996
let idx = cur_len + new_blocks.len();
9097
new_blocks.push(data);

0 commit comments

Comments
 (0)