summaryrefslogtreecommitdiff
path: root/test/example/relooper-fuzz.c
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2018-11-21 08:59:13 -0800
committerGitHub <noreply@github.com>2018-11-21 08:59:13 -0800
commit6cc2bb302d5729c76da42dc0815d6dbba645d952 (patch)
tree11e60856b2028e73df98eeaea2f0b789c50c8cd1 /test/example/relooper-fuzz.c
parent44335674936254ef6f8695883e4376a9d5fd1521 (diff)
downloadbinaryen-6cc2bb302d5729c76da42dc0815d6dbba645d952.tar.gz
binaryen-6cc2bb302d5729c76da42dc0815d6dbba645d952.tar.bz2
binaryen-6cc2bb302d5729c76da42dc0815d6dbba645d952.zip
Relooper CFG optimizations (#1759)
Previously the relooper would do some optimizations when deciding when to use an if vs a switch, how to group blocks, etc. This PR adds an additional pre-optimization phase with some basic but useful simplify-cfg style passes, * Skip empty blocks when they have just one exit. * Merge exiting branches when they are equivalent. * Canonicalize block contents to make such comparisons more useful. * Turn a trivial one-target switch into a simple branch. This can help in noticeable ways when running the rereloop pass, e.g. on LLVM wasm backend output. Also: * Binaryen C API changes to the relooper, which now gets a Module for its constructor. It needs it for the optimizations, as it may construct new nodes. * Many relooper-fuzzer improvements. * Clean up HashType usage.
Diffstat (limited to 'test/example/relooper-fuzz.c')
-rw-r--r--test/example/relooper-fuzz.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/example/relooper-fuzz.c b/test/example/relooper-fuzz.c
index 2b8744d5e..606274683 100644
--- a/test/example/relooper-fuzz.c
+++ b/test/example/relooper-fuzz.c
@@ -62,7 +62,7 @@ int main() {
// contents of main() begin here
- RelooperRef relooper = RelooperCreate();
+ RelooperRef relooper = RelooperCreate(module);
RelooperBlockRef b0;
@@ -223,7 +223,7 @@ int main() {
RelooperAddBranch(b8, b4, NULL, NULL);
- BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, b0, 1, module);
+ BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, b0, 1);
int decisions[] = { 89, 12, 78, 149, 118, 179, 127, 80, 21, 34, 119, 98, 38, 29, 36, 147, 13, 55, 166, 16, 143, 52, 130, 150, 176, 91, 34 };
int numDecisions = sizeof(decisions)/sizeof(int);