[PATCH] D59462: [WebAssembly] Optimize the number of routing blocks in FixIrreducibleCFG

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 06:47:31 PDT 2019


aheejin added a comment.

In D59462#1435602 <https://reviews.llvm.org/D59462#1435602>, @kripken wrote:

> Thanks for the explanation! I think I understand.
>
> So this patch makes us only create a branch there if we don't happen to fall through to the right place. Does that mean that if we ran some CFG-related pass after this, it would not see a valid CFG? (I guess we don't run such a pass now, but I wonder if we may reorder passes in the future at some point.)


I don't think so.

1. This pass should be the last pass that modifies CFG anyway, considering what this pass does. (There's an exception for exception handling in D48345 <https://reviews.llvm.org/D48345> though)
2. Even if for some reason we have to change after this pass, that pass is responsible for making everything valid, as in other CFG-changing passes. That does not change whether the pass is before or after this pass.
3. Additionally, even if we add some branches here, I don't think that hurts the code size. We sort the basic blocks in topological sort in CFGSort pass after this anyway. This pass does not change CFG, meaning it does not change predecessor-successor relationship bertween BBs, but it changes the order of BBs. And based on the new order, it creates or removes branches. For example, in case in the original CFG B was a successor of A and A fell through B but after CFGSort they are not adjacent anymore, the pass inserts a branch from A to B. Or if in the original CFG there was a branch from a to B but after CFGSort B happens to be placed right after A, the pass removes the branch so that A can just fall through.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59462





More information about the llvm-commits mailing list