summaryrefslogtreecommitdiff
path: root/src/support/safe_integer.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-09-26 13:42:35 -0700
committerGitHub <noreply@github.com>2024-09-26 13:42:35 -0700
commit3856a2dc909b3c713497ef311fe4051078ee74b9 (patch)
tree9807dd62c98f9d8d7010bfdc327ea7a081fafd2e /src/support/safe_integer.h
parent2e0a7b53446e55b5b048c2c7559612d19059f5c3 (diff)
downloadbinaryen-3856a2dc909b3c713497ef311fe4051078ee74b9.tar.gz
binaryen-3856a2dc909b3c713497ef311fe4051078ee74b9.tar.bz2
binaryen-3856a2dc909b3c713497ef311fe4051078ee74b9.zip
[NFC-ish] Stop creating unneeded blocks around calls when inlining (#6969)
Inlining was careful about nested calls like this: (call $a (call $b) ) If we inlined the outer call first, we'd have (block $inlined-code-from-a ..code.. (call $b) ) After that, the inner call is a child of a block, not of a call. That is, we've moved the inner call to another parent. To replace that inner call when we inline, we'd need to update the new parent, which would require work. To avoid that work, the pass simply created a block in the middle: (call $a (block (call $b) ) ) Now the inner call's immediate parent will not change when we inline the outer call. However, it turns out that this was entirely unnecessary. We find the calls using a post-order traversal, and we store the actions in a vector that we traverse in order, so we only ever process things in the optimal order of children before parents. And in that order there is no problem: inlining the inner call first leads to (call $a (block $inlined-code-from-b (..code..) ) ) That does not affect the outer call's parent. This PR removes the creation of the unnecessary blocks. This doesn't improve the final output as optimizations remove the unneeded blocks later anyhow, but it does make the code simpler and a little faster. It also makes debugging less confusing. But this is not truly NFC because --inlining (but not --inlining-optimizing) will actually emit fewer blocks now (but only --inlining-optimizing is used by default in production). The diff on tests here is very small when ignoring whitespace. The remaining differences are just emitting fewer obviously-unneeded blocks. There is also one test that needed manual changes, inlining-eh-legacy, because it tested that we do Pop fixups, but after emitting one fewer block, those fixups were not needed. I added a new test there with two nested calls, which does end up needing those fixups. I also added such a test in inlining_all-features so that we have coverage for such nested calls (we might remove the eh-legacy file some day, and other existing tests with nested calls that I found were more complex).
Diffstat (limited to 'src/support/safe_integer.h')
0 files changed, 0 insertions, 0 deletions