[cfe-dev] Linker-unified global objects?

Christian Convey via cfe-dev cfe-dev at lists.llvm.org
Mon Nov 16 10:12:52 PST 2015


Does anyone know where I can find code, or a rule set, which reliably
indicates whether or not two llvm GlobalVariables, or two llvm Functions,
could potentially be unified by the linker based on their attributes such
as linkage-type, visibility, const-ness, 'unnamed_addr`, and initializers?

I'm working on my own AA pass, and it will be unsound if I falsely conclude
that two GlobalVariables or two Functions name distinct pieces of memory,
when in fact that name identical or intersecting regions of memory.
False-positives degrade my precision, but false-negatives make my algorithm
unsound.

David Majnemer kindly pointed to the method areGlobalsPotentiallyEqual(...)
<http://llvm.org/docs/doxygen/html/ConstantFold_8cpp_source.html#l01382>,
but it looks like it gives up easily when external or weak linkage is
involved, so I didn't know if one could do better with a little more effort.

In my case, the current version of clang will always be the front-end, but
the back-end might not be ELF, so I hesitate to draw too many conclusions
just from the GNU assembly I see produced on my system for the little test
cases I come up with.

Note: This is a re-post related to a few threads on llvm-dev, because no
one there seemed to have a definitive answer, and I thought clang folks may
have run into this.
http://lists.llvm.org/pipermail/llvm-dev/2015-November/092116.html
http://lists.llvm.org/pipermail/llvm-dev/2015-November/092221.html

Thanks,
Christian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151116/fbafdf5d/attachment.html>


More information about the cfe-dev mailing list