提交 5b99523d 编写于 作者: A Ariel Ben-Yehuda

rustc_mir::transform::simplify - remove nops first

Removing nops can allow more basic blocks to be merged, but merging
basic blocks can't allow for more nops to be removed, so we should
remove nops first.

This doesn't matter *that* much, because normally we run SimplifyCfg
several times, but there's no reason not to do it.
上级 ca3105cf
......@@ -105,6 +105,8 @@ pub fn new(mir: &'a mut Mir<'tcx>) -> Self {
}
pub fn simplify(mut self) {
self.strip_nops();
loop {
let mut changed = false;
......@@ -141,8 +143,6 @@ pub fn simplify(mut self) {
if !changed { break }
}
self.strip_nops()
}
// Collapse a goto chain starting from `start`
......
......@@ -50,10 +50,10 @@ fn main() {
// StorageLive(_5);
// StorageLive(_6);
// _6 = _4;
// replace(_5 <- _6) -> [return: bb1, unwind: bb7];
// replace(_5 <- _6) -> [return: bb1, unwind: bb5];
// }
// bb1: {
// drop(_6) -> [return: bb8, unwind: bb5];
// drop(_6) -> [return: bb6, unwind: bb4];
// }
// bb2: {
// resume;
......@@ -62,27 +62,21 @@ fn main() {
// drop(_4) -> bb2;
// }
// bb4: {
// goto -> bb3;
// drop(_5) -> bb3;
// }
// bb5: {
// drop(_5) -> bb4;
// drop(_6) -> bb4;
// }
// bb6: {
// goto -> bb5;
// }
// bb7: {
// drop(_6) -> bb6;
// }
// bb8: {
// StorageDead(_6);
// _0 = ();
// drop(_5) -> [return: bb9, unwind: bb3];
// drop(_5) -> [return: bb7, unwind: bb3];
// }
// bb9: {
// bb7: {
// StorageDead(_5);
// drop(_4) -> bb10;
// drop(_4) -> bb8;
// }
// bb10: {
// bb8: {
// StorageDead(_4);
// StorageDead(_2);
// StorageDead(_1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册