[WebAssembly] Fix a bug when mixing TRY/LOOP markers

Summary:
When TRY and LOOP markers are in the same BB and END_TRY and END_LOOP
markers are in the same BB, END_TRY should be _before_ END_LOOP, because
LOOP is always before TRY if they are in the same BB. (TRY is placed in
the latest possible position, whereas LOOP is in the earliest possible
position.)

Reviewers: dschuff

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

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357008 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Heejin Ahn
2019-03-26 17:29:55 +00:00
parent 76db59c4be
commit 15e0c2b138
2 changed files with 35 additions and 1 deletions
@@ -579,7 +579,9 @@ void WebAssemblyCFGStackify::placeTryMarker(MachineBasicBlock &MBB) {
// the END_TRY marker should go after that. Otherwise, the whole try-catch
// is contained within this loop, so the END_TRY should go before that.
if (MI.getOpcode() == WebAssembly::END_LOOP) {
if (EndToBegin[&MI]->getParent()->getNumber() >= Header->getNumber())
// For a LOOP to be after TRY, LOOP's BB should be after TRY's BB; if they
// are in the same BB, LOOP is always before TRY.
if (EndToBegin[&MI]->getParent()->getNumber() > Header->getNumber())
BeforeSet.insert(&MI);
#ifndef NDEBUG
else