The patch partially implements JumpMaps switch statement optimization (refer to "(RFC) JumpMaps: switch statement optimization" on llvm-dev).
The transformation is not fully implemented yet; the code is required for further discussion.
The JumpMaps emission is turned on with --enable-jump-maps flag (disabled by default).
Current caveats:
- no support for PIC model
- search functions are not created / linked automatically, the code generated with optimization needs to be manually linked to __jmfind_x_x functions which (not optimized and generic) implementation can be found in a temporary file jmdev/jmfind.c. The right solution for functions creation / calls / linking are to be discused.
- the analysis pass should be run on a module, not on a function. it is also not up to date with last changes to SelectionDAGBuilder and TargetLowering.
- No regression tests fail with JumpMaps disabled. 8 regression tests fails with enabled JumpMaps are expected and caused by either modifying switch statement lowering (JumpMaps change switches handling so, naturally, basic blocks and emitted code look different) or lack of support for PIC model yet. These tests are: LLVM :: CodeGen/Generic/MachineBranchProb.ll LLVM :: CodeGen/X86/branchfolding-catchpads.ll LLVM :: CodeGen/X86/early-ifcvt.ll LLVM :: CodeGen/X86/switch-bt.ll LLVM :: CodeGen/X86/switch-edge-weight.ll LLVM :: CodeGen/X86/switch.ll LLVM :: CodeGen/X86/tail-merge-unreachable.ll LLVM :: CodeGen/X86/x86-shrink-wrapping.ll