This is an archive of the discontinued LLVM Phabricator instance.

[AsmPrinter] Do not define local aliases for global objects in a comdat

Authored by leonardchan on Apr 3 2020, 1:25 PM.



A global symbol that is defined in a comdat should not generate an alias since call sites that would've referred to that symbol will refer to their own independent local aliases rather than the surviving global comdat one. This could result in something that looks like:

ld.lld: error: relocation refers to a discarded section: .text._ZN3fbl8internal18NullFunctionTargetIvJjjPjEED1Ev.stub
>>> defined in user-x64-clang/obj/system/ulib/minfs/libminfs.a(
>>> section group signature: _ZN3fbl8internal18NullFunctionTargetIvJjjPjEED1Ev.stub
>>> prevailing definition is in user-x64-clang/obj/system/ulib/minfs/libminfs.a(
>>> referenced by function.h:169 (../../zircon/system/ulib/fbl/include/fbl/function.h:169)
>>>     <minfs::Transaction, std::__2::default_delete<minfs::Transaction> >)) in archive user-x64-clang/obj/system/ulib/minfs/libminfs.a

We ran into this when experimenting with a new C++ ABI for fuchsia (refer to D72959) which takes relative offsets between comdat'd functions which is why the normal C++ user wouldn't run into this.

Diff Detail

Event Timeline

leonardchan created this revision.Apr 3 2020, 1:25 PM

Thanks. This is correct.

1 ↗(On Diff #254897)

This may be called semantic-interposition-comdat.ll or similar, just to make the filename clear it is related to semantic interposition.

leonardchan marked an inline comment as done.
MaskRay accepted this revision.Apr 6 2020, 1:13 PM


This revision is now accepted and ready to land.Apr 6 2020, 1:13 PM
This revision was automatically updated to reflect the committed changes.