[PATCH] D80778: [SelectionDAGBuilder][WebAssembly] Omit range checks on jump tables

Thomas Lively via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 28 21:55:34 PDT 2020


tlively created this revision.
tlively added reviewers: aheejin, dschuff, hans, ayonam.
Herald added subscribers: llvm-commits, sunfish, hiraditya, jgravelle-google, sbc100.
Herald added a project: LLVM.

Jump tables on most platforms do not have a default branch target
built in, so LLVM emits a range check before each jump table as long
as the default target for the jump table is reachcable. WebAssembly,
however, implements jump tables using the br_table instruction, which
takes a default branch target as one of its arguments. Since
br_table handles branching to the default target when the argument is
out of range, the range check that LLVM emits is redundant.

This patch adds a TargetLowering setting that disables range checks on
jump tables and adds the default branch target to the end of the
branch target list for each jump table. This allows the WebAssembly
backend to take full advantage of the br_table instruction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80778

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/lib/CodeGen/SwitchLoweringUtils.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/test/CodeGen/WebAssembly/cfg-stackify.ll
  llvm/test/CodeGen/WebAssembly/indirectbr.ll
  llvm/test/CodeGen/WebAssembly/stack-insts.ll
  llvm/test/CodeGen/WebAssembly/switch.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80778.267119.patch
Type: text/x-patch
Size: 12108 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200529/84201f6c/attachment.bin>


More information about the llvm-commits mailing list