diff options
author | Alon Zakai <azakai@google.com> | 2020-12-16 17:26:09 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-16 17:26:09 -0800 |
commit | 4423bcce31d9162c8f8e4262deda5e9278e0e55c (patch) | |
tree | 971e0d74d77b92ab51d905d2c9ea4080b1efe94e /src/wasm.h | |
parent | 83114c51d5aedcb540d578790dbf3173d1775d5c (diff) | |
download | binaryen-4423bcce31d9162c8f8e4262deda5e9278e0e55c.tar.gz binaryen-4423bcce31d9162c8f8e4262deda5e9278e0e55c.tar.bz2 binaryen-4423bcce31d9162c8f8e4262deda5e9278e0e55c.zip |
More refactoring of branch utility code to remove boilerplate. (#3448)
This is almost NFC, but it may emit slightly different IR in cases that
don't matter much. Specifically,
(block (result i32) ;; can also be unreachable
(unreachable)
(i32.const 1)
)
That can be finalized to have type unreachable or i32, as both are
valid. After this PR we should consistently do the same thing in all
places. (Either option would be ok - we prefer to keep the type if
there is one.)
In practice, DCE will remove all the dead code anyhow, leaving no
difference to matter. However, the IR is different without DCE, and
that may be noticeable in an unoptimized build - but it should have
no effect on behavior, just on the binary.
Diffstat (limited to 'src/wasm.h')
-rw-r--r-- | src/wasm.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/wasm.h b/src/wasm.h index bc39eae7b..37c12ffc6 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -703,11 +703,13 @@ public: // needed (which may require scanning the block) void finalize(Type type_); + enum Breakability { Unknown, HasBreak, NoBreak }; + // set the type given you know its type, and you know if there is a break to // this block. this avoids the need to scan the contents of the block in the // case that it might be unreachable, so it is recommended if you already know // the type and breakability anyhow. - void finalize(Type type_, bool hasBreak); + void finalize(Type type_, Breakability breakability); }; class If : public SpecificExpression<Expression::IfId> { |