[LLVMdev] [patch] emit .weak for zero initialized weak variables

Chris Lattner sabre at nondot.org
Mon Dec 18 22:46:53 PST 2006


On Mon, 18 Dec 2006, [UTF-8] Rafael Esp?ndola wrote:
>> I'm not sure this is right.  C code like this:
>>
>> int X;
>>
>> should compile to a .comm directive, not a .weak directive, right?
>
> right.
>
> According to GCC, "int  x" should compile to ".comm   x", but "int x
> __attribute__((weak))" should compile to
> ---------------
> .weak   x
> x:
>        .zero   4
> ---------------
>
> It looks like we have a bug in llvm-gcc, both C codes compile to
> --------------------------
> %x = weak global int 0
> --------------------------

Is there a semantic difference between the two?  Just because GCC compiles 
them to different things, it doesn't mean they do different things...

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/



More information about the llvm-dev mailing list