[LLVMdev] How to deal with potentially unlimited count/length symbol names?

Eli Friedman eli.friedman at gmail.com
Wed Jun 19 10:23:07 PDT 2013


On Wed, Jun 19, 2013 at 1:04 AM, edA-qa mort-ora-y <eda-qa at disemia.com>wrote:

> In my language I have anonymous types (essentially tuples), and I have
> generated functions (like constructors) which are unique for these
> types. If the same type occurs in multiple modules however it should end
> up with only one definition being linked. Thus I need a way to give them
> the same name.
>
> The problem is that if I derive the name from what the type contains the
> length of that name is essential unbound. So how does one generate
> names?  I'm thinking of just using a long hash and hoping I don't get
> accidental collisions. Surely there must be a better way?
>
>
> Currently, since I'm only dealing with one module, it is very easy to
> just assign unique numbers. But obviously this doesn't work with
> multiple independent modules since they'd all need the same name. It
> will ultimately have to work across libraries as well, so I can't just
> create a registry of the type->id.
>
>
I think you've covered all the possible implementations.

In terms of just generating long names, LLVM and common platforms can
handle long names reasonably well because C++ often uses such names.  Also,
the Itanium C++ ABI has a scheme to compress repeated uses of the same type
which might be of interest; see
http://mentorembedded.github.io/cxx-abi/abi.html#mangling-compression .

In terms of a registry, you might want to consider whether these helpers
actually need to be exposed across libraries.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130619/19f1f06a/attachment.html>


More information about the llvm-dev mailing list