Skip to content

Commit bd5fb18

Browse files
committed
---
yaml --- r: 273873 b: refs/heads/beta c: 605bc04 h: refs/heads/master i: 273871: 3d33e5d
1 parent fdfae38 commit bd5fb18

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
@@ -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: 63321ca19390535795780ce15991b6238fb67db4
26+
refs/heads/beta: 605bc042646ef0dc0bd6e0420e6bd5a4715c93df
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

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