diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2020-09-10 17:49:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-10 17:49:56 -0700 |
commit | cd6f0d908f0e4c68d72fd476a6e0e7cfb7ae8595 (patch) | |
tree | f5fdb821fffa3dc54c49daa753ae33686553f3dc /src/tools/spec-wrapper.h | |
parent | 739144d96d162b430d5fd54e4fe11b8ce2d34d47 (diff) | |
download | binaryen-cd6f0d908f0e4c68d72fd476a6e0e7cfb7ae8595.tar.gz binaryen-cd6f0d908f0e4c68d72fd476a6e0e7cfb7ae8595.tar.bz2 binaryen-cd6f0d908f0e4c68d72fd476a6e0e7cfb7ae8595.zip |
Simplify BinaryenIRWriter (#3110)
BinaryenIRWriter was previously inconsistent about whether or not it
emitted an instruction if that instruction was not reachable.
Instructions that produced values were not emitted if they were
unreachable, but instructions that did not produce values were always
emitted. Additionally, blocks continued to emit their children even
after emitting an unreachable child.
Since it was not possible to tell whether an unreachable instruction's
parent would be emitted, BinaryenIRWriter had to be very defensive and
emit many extra `unreachable` instructions around unreachable code to
avoid type errors.
This PR unifies the logic for emitting all non-control flow
instructions and changes the behavior of BinaryenIRWriter so that it
never emits instructions that cannot be reached due to having
unreachable children. This means that extra `unreachable` instructions
now only need to be emitted after unreachable control flow
constructs. BinaryenIRWriter now also stops emitting instructions
inside blocks after the first unreachable instruction as an extra
optimization.
This change will also simplify Poppy IR stackification (see #3059) by
guaranteeing that instructions with unreachable children will not be
emitted into the stackifier. This makes satisfying the Poppy IR rule
against unreachable Pops trivial, whereas previously satisfying this
rule would have required about about 700 additional lines of code to
recompute the types of all unreachable children for any instruction.
Diffstat (limited to 'src/tools/spec-wrapper.h')
0 files changed, 0 insertions, 0 deletions