[llvm-dev] "no-jump-table": Attribute vs flag

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 10 12:41:43 PDT 2017


On 7/10/2017 8:55 AM, Sumanth Gundapaneni via llvm-dev wrote:
>
> The clang flag “-fno-jump-table” adds the function attribute 
> “no-jump-table=true” to IR.
>
> What are facts that need to take in to consideration whether to pass 
> an llvm flag to the clang driver (assuming we have an llvm flag that 
> turns off jump tables ) vs adding an attribute?
>

There are essentially four ways to change the way code generation works 
for a function:

1. Function attributes 
(http://llvm.org/docs/LangRef.html#function-attributes)
2. Module flags (http://llvm.org/docs/LangRef.html#module-flags-metadata)
3. Options passed directly to the target 
(include/llvm/Target/TargetOptions.h etc.)
4. LLVM flags ("-mllvm").

Historically, LLVM flags were the primary way to configure the compiler; 
they're very easy to add, and straightforward to use. But they don't 
really work well if you aren't just invoking a compiler to build an 
object file.  Options are global, so they apply to the entire process, 
which is inconvenient for compiling multiple modules in the same process 
(e.g. a JIT).  And they aren't recorded into IR, so in an LTO workflow 
you have to pass the option to the linker rather than the compiler.  If 
you expect an option is useful outside of developing LLVM itself, you 
should provide some other way to configure it.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170710/48dbff11/attachment.html>


More information about the llvm-dev mailing list