SimplifyCfg: don't incref target when collapsing a goto with 1 pred

This commit is contained in:
Ariel Ben-Yehuda 2016-10-04 16:27:27 +03:00
parent ae51ccfa77
commit 44ac0160ce

View File

@ -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;
}