]> git.lizzy.rs Git - rust.git/commitdiff
SimplifyCfg: simplify the start block
authorAriel Ben-Yehuda <ariel.byd@gmail.com>
Tue, 4 Oct 2016 13:23:01 +0000 (16:23 +0300)
committerAriel Ben-Yehuda <ariel.byd@gmail.com>
Tue, 4 Oct 2016 13:23:01 +0000 (16:23 +0300)
src/librustc_mir/transform/simplify_cfg.rs

index 8e1b7b44976f33c0c2baf8875d646afff8e0ae6d..228fa46884130a2359f1b79ffc64ab7b4160f92e 100644 (file)
@@ -50,6 +50,7 @@ pub fn new(label: &'a str) -> Self {
 
 impl<'l, 'tcx> MirPass<'tcx> for SimplifyCfg<'l> {
     fn run_pass<'a>(&mut self, _tcx: TyCtxt<'a, 'tcx, 'tcx>, _src: MirSource, mir: &mut Mir<'tcx>) {
+        debug!("SimplifyCfg({:?}) - simplifying {:?}", self.label, mir);
         CfgSimplifier::new(mir).simplify();
         remove_dead_blocks(mir);
 
@@ -78,6 +79,8 @@ fn new(mir: &'a mut Mir<'tcx>) -> Self {
 
         // we can't use mir.predecessors() here because that counts
         // dead blocks, which we don't want to.
+        pred_count[START_BLOCK] = 1;
+
         for (_, data) in traversal::preorder(mir) {
             if let Some(ref term) = data.terminator {
                 for &tgt in term.successors().iter() {