[PATCH] SimplifyCFG: don't remove unreachable defaults from switch instructions; exploit them instead!
Hans Wennborg
hans at chromium.org
Mon Dec 1 18:01:34 PST 2014
Hi rnk, majnemer, eeckstein,
This patch actually does a number of related things. I'm happy to split it up if it makes reviewing easier:
1. Teach SelectionDAG lowering about unreachable defaults by folding the most popular case destination into the default, which is what SimplifyCFG does today. I investigated exploiting the unreachable more aggressively, e.g. by omitting range checks for jump tables, but it couldn't be done without size regression and it might have security implications.
2. Make SimplifyCFG stop removing unreachable defaults so they can be exploited by other transformations.
3. Omit range checks in switch-to-lookup table formation if the default is unreachable. This saves 64 kB off a Clang bootstrap on 64-bit Linux. No effect on Chromium unfortunately.
4. Make ConstantFoldTerminator() work when faced with unreachable default.
5. Make TurnSwitchRangeIntoICmp() work with unreachable default. This also makes us handle some cases we'd previously get wrong, see the unreachable2 test.
Please take a look!
http://reviews.llvm.org/D6471
Files:
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/Transforms/Utils/Local.cpp
lib/Transforms/Utils/SimplifyCFG.cpp
test/CodeGen/X86/2013-10-14-FastISel-incorrect-vreg.ll
test/CodeGen/X86/asm-label.ll
test/CodeGen/X86/switch-jump-table.ll
test/Transforms/SimplifyCFG/UnreachableEliminate.ll
test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
test/Transforms/SimplifyCFG/switch-range-to-icmp.ll
test/Transforms/SimplifyCFG/switch-to-br.ll
test/Transforms/SimplifyCFG/switch-to-select-two-case.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6471.16794.patch
Type: text/x-patch
Size: 24919 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141202/4b59830f/attachment.bin>
More information about the llvm-commits
mailing list