[PATCH] D77181: [WebAssembly] Fix subregion relationship in CFGSort

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 15:59:55 PDT 2020


aheejin created this revision.
aheejin added a reviewer: dschuff.
Herald added subscribers: llvm-commits, sunfish, hiraditya, jgravelle-google, sbc100.
Herald added a project: LLVM.

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. Prevously 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 excptions), MachineLoop may not,
because MachineLoop does not contain BBs that don't have a pass 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 pass 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77181

Files:
  llvm/lib/Target/WebAssembly/WebAssemblyCFGSort.cpp
  llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77181.254025.patch
Type: text/x-patch
Size: 7351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200331/1c43c9be/attachment.bin>


More information about the llvm-commits mailing list