[PATCH] D59740: [WebAssembly] Don't analyze branches after CFGStackify

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 23 12:58:08 PDT 2019


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

`WebAssembly::analyzeBranch` now does not analyze anything if the
function is CFG stackified. We were previously doing similar things by
checking if a branch's operand is whether an integer or an MBB, but this
failed to bail out when a BB did not have any terminators.

Consider this case:

  bb0:
    try $label0
    call @foo    // unwinds to %ehpad
  bb1:
    ...
    br $label0   // jumps to %cont. can be deleted
  ehpad:
    catch
    ...
  cont:
    end_try

Here `br $label0` will be deleted in CFGStackify's
`removeUnnecessaryInstrs` function, because we jump to the %cont block
even without the branch. But in this case, MachineVerifier fails to
verify this, because `ehpad` is not a successor of `bb1` even if `bb1`
does not have any terminators. MachineVerifier incorrectly thinks `bb1`
falls through to the next block.

This pass now consistently rejects all analysis after CFGStackify
whether a BB has terminators or not, also making the MachineVerifier
work. (MachineVerifier does not try to verify relationships between BBs
if `analyzeBranch` fails, the behavior we want after CFGStackify.)

This also adds a new option `-wasm-disable-ehpad-sort` for testing. This
option helps create the sorted order we want to test, and without the
fix in this patch, the tests in cfg-stackify-eh.ll fail at
MachineVerifier with `-wasm-disable-ehpad-sort`.


Repository:
  rL LLVM

https://reviews.llvm.org/D59740

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59740.192013.patch
Type: text/x-patch
Size: 5047 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190323/6092f2e9/attachment.bin>


More information about the llvm-commits mailing list