Quuxplusone added a comment.

If the goal is fine-grained control over the heuristics for compiling switch 
statements, perhaps one should enumerate all the possible ways to lower switch 
statements --- jump-tables, lookup-tables, if-trees, if-chains, (more?) --- and 
add a separate flag for each of them.
...Although I'm not sure what purpose there'd really be in saying "This switch 
statement *must* be compiled into an if-else tree" or "this one *must* be a 
lookup table"; couldn't that end up being a pessimization one day, as the 
optimizer gets smarter?

Either way, it sounds like "-fno-switch-tables" is just a synonym for the 
(soon-to-be-)existing options "-fno-jump-tables -fno-lookup-tables" and 
therefore doesn't need to exist as a separate option.

Question: Is the intention really specifically about switch heuristics? Or are 
you trying to prevent the compiler from embedding data into the text section 
and/or taking computed jumps? Because Clang *can* generate a lookup table in 
.rodata even if the input code contains no "switch" constructs --- e.g. a long 
enough chain of "if"s will do the trick. https://godbolt.org/g/ZQqkaB


https://reviews.llvm.org/D35578



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to