diff options
author | Thomas Lively <tlively@google.com> | 2020-06-02 13:14:27 -0700 |
---|---|---|
committer | Thomas Lively <tlively@google.com> | 2020-06-02 13:14:27 -0700 |
commit | f99d5f8c32a822580a732d15a34e8197da55d22b (patch) | |
tree | fd11544b8f8d44e1a30e9cf2d3ed3b8d3eecb5e8 /llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | |
parent | d61ad660503d2e0c7ba9981ba6526ae0c2f3b7cc (diff) | |
download | llvm-f99d5f8c32a822580a732d15a34e8197da55d22b.zip llvm-f99d5f8c32a822580a732d15a34e8197da55d22b.tar.gz llvm-f99d5f8c32a822580a732d15a34e8197da55d22b.tar.bz2 |
[WebAssembly] Eliminate range checks on br_tables
Summary:
Jump tables for most targets cannot handle out of range indices by
themselves, so LLVM emits range checks to guard the jump
tables. WebAssembly, on the other hand, implements jump tables using
the br_table instruction, which takes a default branch target as an
operand, making the range checks redundant. This patch introduces a
new MachineFunction pass in the WebAssembly backend to find and
eliminate the redundant range checks.
Reviewers: aheejin, dschuff
Subscribers: mgorny, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D80863
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index ca098427..7bf655c9 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -406,6 +406,10 @@ bool WebAssemblyPassConfig::addInstSelector() { // it's inconvenient to collect. Collect it now, and update the immediate // operands. addPass(createWebAssemblySetP2AlignOperands()); + + // Eliminate range checks and add default targets to br_table instructions. + addPass(createWebAssemblyFixBrTableDefaults()); + return false; } |