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

Rafael Espíndola
2014-08-28T20:26:37Z

On 28 August 2014 15:26, Akira Hatanaka <ahatanak at gmail.com>
wrote:
> I noticed that some of the passes are creating GlobalVariables that should
> be merged using InternalLinkage instead of PrivateLinkage. For example,
> global array ".memset_pattern" created by LoopIdiomRecognize has
> InternalLinkage. Since these constants won't be prefixed with
"L" or "l",
> will these constants be placed in section __const too?

Correct.

> Your patch isn't
> preventing any constants that could be merged before from being merged, but
> it just seems to me that those constants should go into the mergeable
> sections too, like "switch.table" does.

They should use private linkage then. It seems an unavoidable
consequence of the ld64 restriction. Since it requires mergeable
constants to start with 'l' or 'L', we have to use a linkage
that
allows LLVM to remove the symbol from the symbol table. That linkage
is private.

> Otherwise, the patch looks fine to me.

r216682.

Cheers,
Rafael