This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Fix bugs in BLOCK/TRY placement
ClosedPublic

Authored by aheejin on Mar 23 2019, 12:24 PM.

Details

Summary

Before we placed all TRY/END_TRY markers before placing BLOCK/END_BLOCK
markers. This couldn't handle this case:

bb0:
  br bb2
bb1:          // nearest common dominator of bb3 and bb4
  ...
bb2:
  br_if ... bb3                                                        
  br bb4
bb3:
  call @foo   // unwinds to ehpad
bb4:
  call @bar   // unwinds to ehpad
ehpad:
  catch
  ...

When we placed TRY markers, we placed it in bb1 because it is the
nearest common dominator of bb3 and bb4. But because bb0 jumps to bb2,
when we placed block markers, we ended up with interleaved scopes like

block
try
end_block
catch
end_try

which was not correct.

This patch fixes the bug by placing BLOCK and TRY markers in one pass
while iterating BBs in a function. This also adds some more routines to
placeTryMarkers, because we now have to assume that there can be
previously placed BLOCK and END_BLOCK.

Diff Detail

Repository
rL LLVM

Event Timeline

aheejin created this revision.Mar 23 2019, 12:24 PM
aheejin edited the summary of this revision. (Show Details)Mar 23 2019, 12:25 PM
aheejin edited the summary of this revision. (Show Details)
aheejin marked an inline comment as done.Mar 23 2019, 12:28 PM
aheejin added inline comments.
lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
485 ↗(On Diff #192011)

Here the comment was previously incorrect

dschuff accepted this revision.Mar 25 2019, 1:41 PM

otherwise LGTM

test/CodeGen/WebAssembly/cfg-stackify-eh.ll
2 ↗(On Diff #192011)

Should we remove -fast-isel=false from the RUN line? As it is, this doesn't test a common configuration (i.e. O0 but with DAG ISel).

This revision is now accepted and ready to land.Mar 25 2019, 1:41 PM
aheejin updated this revision to Diff 192289.Mar 26 2019, 9:59 AM
aheejin marked an inline comment as done.
  • Remove -fast-isel=false
This revision was automatically updated to reflect the committed changes.