[LLVMdev] AsmPrinter behavior

Nathan Jeffords blunted2night at gmail.com
Fri May 7 09:51:55 PDT 2010


On Fri, May 7, 2010 at 9:01 AM, Chris Lattner <clattner at apple.com> wrote:

>
> On May 7, 2010, at 12:39 AM, Nathan Jeffords wrote:
>
> On Fri, May 7, 2010 at 12:03 AM, Chris Lattner <clattner at apple.com> wrote:
>
>>
>> On May 6, 2010, at 10:01 PM, Nathan Jeffords wrote:
>>
>> > I compile these two lines in llc
>> >
>> > @tst1 = internal global [4 x i8] zeroinitializer;
>> > @tst2 = internal global [4 x i8] [i8 0, i8 1, i8 2, i8 3];
>> >
>> > @tst1 is emited via MCStreamer::EmitCommonSymbol
>> > while the other is emited via MCStreamer::EmitLabel followed by
>> MCStreamer::EmitBytes
>> >
>> > from what I can tell, only symbols with common linkage should me emitted
>> by MCStreamer::EmitCommonSymbol,
>> >
>> > is this the expected behavior or should I fix it?
>>
>> This is expected behavior.  tst1 should be emitted with something like:
>>
>> .local _tst1
>> .comm _tst1, ...
>>
>> based on the exact syntax of your target.  If your target supports .lcomm,
>> you can also enable that.
>>
>> -Chris
>
>
> This seems counter intuitive to me, I can understand that C assigned that
> behavior somewhat arbitrarily to uninitialized global variables, but in LLVM
> there is explicitly a common linkage attribute to get that behavior. Nothing
> in the llvm language reference indicates the behavior of a global with the
> 'internal' linkage attribute should change based of the values used to
> initialize it.
>
>
> I don't follow.  The object file format provides a means for efficiently
> zero filling a local symbol.  The compiler is just using it.  What is the
> problem you're trying to solve here?  Since it is not exported out of the .o
> file (it is local) there whether it is "common" or not is undetectable, we
> just get a storage optimization.
>
>
I don't know, I see common and it makes me think that things are getting
merged together, but as you say it is local so the fact that its also common
becomes irrelevant. In MachO do you just put these into the .bss section?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100507/2f076dfa/attachment.html>


More information about the llvm-dev mailing list