[PATCH] D91513: [DeadMachineInstrctionElim] Iteratively run DeadMachineInstrcutionElim pass untill nothing dead

guopeilin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 16 17:25:34 PST 2020


guopeilin added a comment.

In D91513#2397313 <https://reviews.llvm.org/D91513#2397313>, @hliao wrote:

> could you elaborate more on why we need to run that iteratively? since the original one runs bottom-up, supposedly it should find all.

>From the `iteratively-run-dead-mi-elim.mir` we can see that `bb.5` defines `%6`, and `%6` is used in `bb.2`. When we traverse the all basic blocks, that is, we runs bottome-up, we will meet `bb.5` first, for `%6`, we find that it is not dead cause  `%3` in `bb.2` use it. So `%6` surrive. Then we continue traverse other BBs, When we meet `bb.2`, we see that no one use `%5`, so we kill it. So as `%4`, `%3`. Right now, actually `%6` becomes dead cause we kill `%3` thus there is no longer any one uses `%6`. 
However, cause we only traverse blocks once, we can't erase `%6` at the end. So if we iteratively visit all blocks until nothing change, then we can ensure that all dead mi is erased.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91513/new/

https://reviews.llvm.org/D91513



More information about the llvm-commits mailing list