[LLVMdev] [PATCH] print .weak directives
Chris Lattner
sabre at nondot.org
Sun Dec 10 13:53:11 PST 2006
On Sat, 9 Dec 2006, [UTF-8] Rafael Esp?ndola wrote:
>> I'm sorry, I must be missing something here:
>>
>> In order to have weak linkage (I'm ignoring external weak for the moment)
>> a global has to be defined in the LLVM code. Because it is defined in the
>> LLVM code, it will have to be printed out by the target asm printer
>> somewhere. When that happens, it will get a .weak directive emitted for
>> it.
> It should, but currently we don't print it:
> ----------------------------------
> %a = weak global int 0
> ---------------------------------
> .comm a,4,4
> --------------------------------
> In fact, a bug in my patch is that with it we print both a .comm and a .weak :-(
Ah ok, the bug there is that a variable can't be .comm if it is weak.
>> External weak globals are different: since they are not defined in the .ll
>> file, it is not as simple to know whether or not to print them. There are
>> two ways to handle them:
>
> I see. I was trying to handle them the same way since we were missing
> .weak directives for both, but they must be handled differently.
Ok.
> I see now that we have two problems:
>
> 1) print .weak directives for locally defined weak globals
> 2) print .weak directives for used external weak symbols
>
> I will try to submit one patches for each problem. For the second one
> I like 1b the best. Maybe we could use only one set (in AsmPrinter).
> Both the AsmPrinter code and the back end specific code would add
> symbols to it when they see a use of an external weak symbol and the
> AsmPrinter would emit the directives in doFinalization.
Sounds good!
-Chris
--
http://nondot.org/sabre/
http://llvm.org/
More information about the llvm-dev
mailing list