[LLVMdev] How to tell whether a GlobalValue is user-defined

Reid Kleckner rnk at google.com
Mon Aug 25 11:38:18 PDT 2014


On Mon, Aug 25, 2014 at 9:54 AM, Nick Kledzik <kledzik at apple.com> wrote:
>
> The literalN sections were developed long ago to support coalescing of
> unnamed constants like 9.897 in source code for architectures that could
> not embed large constants in instructions.  The linker could knew how to
> break up the section (e.g. __literal8 is always 8 byte chunks) and coalesce
> copies by content.
>
> ~6 years ago we discovered that gcc would sometimes put user named
> constants into the literal sections (e.g. const double foo 9.897).  This
> was an issue because C language rules say &a != &b, but if ‘a’ and ‘b’ are
> the contain the same literal value from different translation units, the
> linker could merge them to the same address.  For whatever reason, we could
> not fix gcc, so we changed to linker to never coalesce items in literal
> sections if there was a (non ‘L’ and non ‘l’) symbol on it.
>

Thanks for the info!


> The current state of LLVM is that is it going out of its way to move
> “named” constants from __const section to __literalN section. But the only
> possible advantage to doing that is that the hopes that the linker might
> coalesce it.  But the linker won’t coalesce it because it is named.  So, is
> there a way to keep the named values in the __const section?
>

Right, LLVM has proven that the address of the data is insignificant, hence
it is "unnamed", and can be placed in a mergeable section. Is there any
reason not to change the linker to merge this stuff, if gcc is no longer
supported? We won't violate the semantics of C. Is there some immediate
problem with keeping the data in these sections?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140825/12a1aefe/attachment.html>


More information about the llvm-dev mailing list