summaryrefslogtreecommitdiff
path: root/src/passes/MergeLocals.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-04-29 12:57:10 -0700
committerGitHub <noreply@github.com>2021-04-29 12:57:10 -0700
commitb9c7497d1caae695ac5582590d73ad61abd7850f (patch)
treebb3d6f90608a884b3c23a234cfd5b3cf6e5b3a34 /src/passes/MergeLocals.cpp
parent59cc7e3d0a25051177a5c98d8c8bbe5f68c51da8 (diff)
downloadbinaryen-b9c7497d1caae695ac5582590d73ad61abd7850f.tar.gz
binaryen-b9c7497d1caae695ac5582590d73ad61abd7850f.tar.bz2
binaryen-b9c7497d1caae695ac5582590d73ad61abd7850f.zip
Add LocalGraph::equivalent (#3848)
This compares two local.gets and checks whether we are sure they are equivalent, that is, they contain the same value. This does not solve the general problem, but uses the existing info to get a positive answer for the common case where two gets only receive values by a single set, like (local.set $x ..) (a use.. (local.get $x)) (another use.. (local.get $x)) If they only receive values from the same single set, then we know it must dominate them. The only risk is that the set is "in between" the gets, that is, that the set occurs after one get and before the other. That can happen in a loop in theory, (loop $loop (use (local.get $x)) (local.set $x ..some new value each iteration..) (use (local.get $x)) (br_if $loop ..) ) Both of those gets receive a value from the set, and they may be different values, from different loop iterations. But as mentioned in the source code, this is not a problem since wasm always has a zero-initialization value, and so the first local.get in that loop would have another set from which it can receive a value, the function entry. (The only way to avoid that is for this entire code to be unreachable, in which case nothing matters.) This will be useful in dead store elimination, which has to use this to reason about references and pointers in order to be able to do anything useful with GC and memory.
Diffstat (limited to 'src/passes/MergeLocals.cpp')
0 files changed, 0 insertions, 0 deletions