[PATCH] D87207: [WebAssembly] Fix fixEndsAtEndOfFunction for try-catch
Heejin Ahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 6 12:00:43 PDT 2020
aheejin created this revision.
aheejin added reviewers: dschuff, tlively.
Herald added subscribers: llvm-commits, ecnelises, sunfish, hiraditya, jgravelle-google, sbc100.
Herald added a project: LLVM.
aheejin requested review of this revision.
When the function return type is non-void and `end` instructions are at
the very end of a function, CFGStackify's `fixEndsAtEndOfFunction`
function fixes the corresponding block/loop/try's type to match the
function's return type. This is applied to consecutive `end` markers at
the end of a function. For example, when the function return type is
`i32`,
block i32 ;; return type is fixed to i32
...
loop i32 ;; return type is fixed to i32
...
end_loop
end_block
end_function
But try-catch is a little different, because it consists of two parts:
a try part and a catch part, and both parts' return type should satisfy
the function's return type. Which means,
try i32 ;; return type is fixed to i32
...
block i32 ;; this should be changed i32 too!
...
end_block
catch
...
end_try
end_function
As you can see in this example, it is not sufficient to only `end`
instructions at the end of a function; in case of `try`, we should
check instructions before `catch`es, in case their corresponding `try`'s
type has been fixed.
This changes `fixEndsAtEndOfFunction`'s algorithm to use a worklist
that contains a reverse iterator, each of which is a starting point for
a new backward `end` instruction search.
Fixes https://bugs.llvm.org/show_bug.cgi?id=47413.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87207
Files:
llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87207.290147.patch
Type: text/x-patch
Size: 6048 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200906/73f36078/attachment.bin>
More information about the llvm-commits
mailing list