[WebAssembly] Fix subregion relationship in CFGSort

Authored by aheejin on Mar 30 2020, 3:42 AM.


[WebAssembly] Fix subregion relationship in CFGSort

The previous code for determining the innermost region in CFGSort was
not correct. We determine subregion relationship by domination of their
headers, i.e., if region A's header dominates region B's header, B is a
subregion of A. Previously we assumed that if a BB belongs to both a
loop and an exception, the region with fewer number of BBs is the
innermost one. This may not be true, because while WebAssemblyException
contains BBs in all its subregions (loops or exceptions), MachineLoop
may not, because MachineLoop does not contain BBs that don't have a path
to its header even if they are dominated by its header.

  Loop header  <---|
      |            |
Exception header   |
      | \          |
      A  B         |
      |   \        |
      |    C       |
      |            |
  Loop latch       |
      |            |

For example, in this CFG, the loop does not contain B and C, because
they don't have a path back to the loops header. But for CFGSort we
consider the exception here belongs to the loop and the exception should
be a subregion of the loop and scheduled together.

So here we should use WE->contains(ML->getHeader()) (but not
ML->contains(WE->getHeader()), for the stated region above).

This also fixes some comments and deletes Regions vector in
RegionInfo class, which was not used anywere.

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77181