Hi Bob,
>>>> So, after long rounds to define how the build attributes are
going to
>>>> be represented in IR, and after Jason has implemented build
attributes
>>>> in MC, I have a proposal on how to represent this in IR.
>>>>
>>>> First, we need to distinguish between target dependent and
independent
>>>> attributes. Generic things like optimization level, specific
>>>> optimizations, use of vector instructions, use of exceptions,
>>>> floating-point compatibility can all go in to the generic list
of
>>>> attributes.
>>>
>>> I don't see why you would want to put any of these things in
the module
>>> at all:
>>
>> In fact they are more suitable as function attributes. For example, we
already have function attributes for -Os.
>
> I think some of this discussion is missing the context. ARM has defined
per-object file build attributes to record things like the optimization level,
whether the code is ARM vs. Thumb, etc. This is not something new nor is it
specific to LLVM. As far as I know, the linker is not obligated to do anything
with this information, but compilers that follow ARM's specifications are
expected to provide it.
>
> Putting the build attributes on individual functions is not a good match
for the final result, which is a single set of attributes for the entire object
file. If you put separate attributes on the functions, then code gen will have
to scan all the functions to see if they have the same attribute values.
thanks for the explanation. Perhaps you can use global asm statements for this
(see http://llvm.org/docs/LangRef.html#moduleasm )? These can be used to inject
arbitrary strings into the assembler. Dragonegg uses this to provide an
"ident"
string like this:
$ gcc-4.5 -fplugin=dragonegg.so -S -o - -flto empty.c
; ModuleID = 'empty.c'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-unknown-linux-gnu"
module asm "\09.ident\09\22GCC: (GNU) 4.5.2 20101028 (prerelease) LLVM:
118890\22"
In the assembler output this gives:
$ gcc-4.5 -fplugin=dragonegg.so -S -o - empty.c
.file "empty.c"
.ident "GCC: (GNU) 4.5.2 20101028 (prerelease) LLVM: 118890"
.section .note.GNU-stack,"", at progbits
Ciao,
Duncan.