Skip to content

Commit

Permalink
SimplifyCfg: don't incref target when collapsing a goto with 1 pred
Browse files Browse the repository at this point in the history
  • Loading branch information
arielb1 committed Oct 4, 2016
1 parent ae51ccf commit 44ac016
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/librustc_mir/transform/simplify_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,16 @@ impl<'a, 'tcx: 'a> CfgSimplifier<'a, 'tcx> {
debug!("collapsing goto chain from {:?} to {:?}", *start, target);

*changed |= *start != target;
self.pred_count[target] += 1;
self.pred_count[*start] -= 1;

if self.pred_count[*start] == 1 {
// This is the last reference to *start, so the pred-count to
// to target is moved into the current block.
self.pred_count[*start] = 0;
} else {
self.pred_count[target] += 1;
self.pred_count[*start] -= 1;
}

*start = target;
}

Expand Down

0 comments on commit 44ac016

Please sign in to comment.