[LLVMdev] [RFC] Passing Options to Different Parts of the Compiler Using Attributes
Bill Wendling
wendling at apple.com
Mon Nov 26 13:41:32 PST 2012
On Nov 26, 2012, at 1:20 PM, Bill Wendling <wendling at apple.com> wrote:
> On Nov 20, 2012, at 11:03 AM, Meador Inge <meadori at codesourcery.com> wrote:
>
>> 3. Can attribute groups and single attributes be inter-mixed?
>> For example:
>>
>> void @foo attrgroup(#1) alwaysinline attrgroup(#2) nounwind
>>
> This will be necessary for backwards compatibility. However, running this through this sequence:
>
> $ llvm-as < foo.ll | llvm-dis
>
> would produce:
>
> attrgroup #1 = { ... }
> attrgroup #2 = { ... }
> attrgroup #3 = { alwaysinline, nounwind }
>
> void @foo() attrgroup(#1) attrgroup(#2) attrgroup(#3)
>
> This is because of how the attributes will be represented internally to LLVM. Let me know if you have strong objections to this.
>
Now that I think about it, this isn't the output. Here's what it would look like:
a.ll:
attributes #1 = { "no-sse" }
attributes #2 = { noredzone }
define void @foo() #1 #2 alwaysinline nounwind { ret void }
Here's the output:
$ llvm-as < a.ll | llvm-dis
attributes #1 = { "no-sse" }
attributes #2 = { noredzone }
attributes #3 = { "no-sse", noredzone, alwaysinline, nounwind }
define void @foo() #3 { ret void }
This is because all of the attribute groups that a function references will be merged into one attribute object. When we output the attribute object, we don't know that the original function referred to two attribute groups and had a couple of extra attributes defined.
In practice, I expect this to happen rarely in non-LTO mode.
-bw
More information about the llvm-dev
mailing list