This is an archive of the discontinued LLVM Phabricator instance.

[LangRef] Clarify comdat
ClosedPublic

Authored by MaskRay on Jul 19 2021, 12:06 PM.

Details

Summary
  • ELF supports nodeduplicate.
  • ELF calls the concept "section group". GRP_COMDAT emulates the PE COMDAT deduplication feature.
  • "COMDAT group" is an ELF term. Avoid it for PE/COFF.
  • WebAssembly supports comdat but only supports the any selection kind. https://bugs.llvm.org/show_bug.cgi?id=50531
  • A comdat must be included or omitted as a unit. Both the compiler and the linker must obey this rule.
  • A global object can be a member of at most one comdat.
  • COFF requires a non-local linkage for non-nodeduplicate selection kinds.

Diff Detail

Event Timeline

MaskRay created this revision.Jul 19 2021, 12:06 PM
MaskRay requested review of this revision.Jul 19 2021, 12:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2021, 12:06 PM
MaskRay edited the summary of this revision. (Show Details)Jul 19 2021, 12:10 PM
MaskRay edited the summary of this revision. (Show Details)
MaskRay added inline comments.
llvm/docs/LangRef.rst
953

I'll move WebAssembly to a separate list item.

dschuff added inline comments.Jul 19 2021, 2:35 PM
llvm/docs/LangRef.rst
944–945

This wording is confusing: the term "noduplicates" seems to be in conflict with the idea that no deduplication is performed (which could result in there being duplicates in the output). Is that intentional? Does it mean that the compiler must ensure that there are no duplicates (which would allow the linker to skip deduplication)? If so, I think ti would be good to clarify.

MaskRay added inline comments.Jul 19 2021, 2:43 PM
llvm/docs/LangRef.rst
944–945

I agree that noduplicates is confusing. The word says the opposite to that the implementation actually does...

I will send a patch to renaming it...

dschuff added inline comments.Jul 19 2021, 2:52 PM
llvm/docs/LangRef.rst
944–945

Sounds good. I don't think that needs to block this CL though, if it describes the current situation accurately. I'll let @sbc100 take a look from the wasm side too though.

MaskRay marked an inline comment as done.Jul 19 2021, 3:11 PM
MaskRay added inline comments.
llvm/docs/LangRef.rst
944–945

Sent D106319 to rename noduplicates to nodeduplicate.

The IR name has the PE origin IMAGE_COMDAT_SELECT_NODUPLICATES which IMHO is not an ideal name.

MaskRay updated this revision to Diff 360332.Jul 20 2021, 6:17 PM
MaskRay marked an inline comment as done.
MaskRay edited the summary of this revision. (Show Details)

rebase after noduplicates->nodeduplicate renaming

MaskRay updated this revision to Diff 360964.Jul 22 2021, 2:10 PM
MaskRay retitled this revision from [LangRef] Clarify comdat to [LangRef] Clarify comdat and llvm.global_ctors/llvm.global_dtors.
MaskRay edited the summary of this revision. (Show Details)

Clarify llvm.global_ctors

MaskRay updated this revision to Diff 360981.Jul 22 2021, 2:40 PM
MaskRay retitled this revision from [LangRef] Clarify comdat and llvm.global_ctors/llvm.global_dtors to [LangRef] Clarify comdat.
MaskRay edited the summary of this revision. (Show Details)

Drop llvm.global_ctors change

ELF probably should use SHF_LINK_ORDER instead to avoid the ldc compiler's confusion

rnk accepted this revision.Jul 23 2021, 3:37 PM

Looks good to me

This revision is now accepted and ready to land.Jul 23 2021, 3:37 PM
This revision was landed with ongoing or failed builds.Jul 23 2021, 4:33 PM
This revision was automatically updated to reflect the committed changes.