OSDN Git Service

[WebAssembly] Optimize Irreducible Control Flow
authorHeejin Ahn <aheejin@gmail.com>
Thu, 3 Jan 2019 23:10:11 +0000 (23:10 +0000)
committerHeejin Ahn <aheejin@gmail.com>
Thu, 3 Jan 2019 23:10:11 +0000 (23:10 +0000)
commit0db40de6caaadd26563457643d38e1c51de0f48e
treea19649c953572fdae2e059ec9af485341f2edef9
parent976e457274e43903f4147160585a7b63cc8de4f4
[WebAssembly] Optimize Irreducible Control Flow

Summary:
Irreducible control flow is not that rare, e.g. it happens in malloc and
3 other places in the libc portions linked in to a hello world program.
This patch improves how we handle that code: it emits a br_table to
dispatch to only the minimal necessary number of blocks. This reduces
the size of malloc by 33%, and makes it comparable in size to asm2wasm's
malloc output.

Added some tests, and verified this passes the emscripten-wasm tests run
on the waterfall (binaryen2, wasmobj2, other).

Reviewers: aheejin, sunfish

Subscribers: mgrang, jgravelle-google, sbc100, dschuff, llvm-commits

Differential Revision: https://reviews.llvm.org/D55467

Patch by Alon Zakai (kripken)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350367 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp
test/CodeGen/WebAssembly/irreducible-cfg-exceptions.ll [new file with mode: 0644]
test/CodeGen/WebAssembly/irreducible-cfg-nested.ll [new file with mode: 0644]
test/CodeGen/WebAssembly/irreducible-cfg-nested2.ll [new file with mode: 0644]
test/CodeGen/WebAssembly/irreducible-cfg.ll