This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Create COMDAT group for OpenMP offload registration code to avoid multiple copies
ClosedPublic

Authored by sdmitriev on May 24 2017, 11:08 AM.

Details

Summary

Existing OpenMP code generation in clang adds the same OpenMP registration code and associated data to every object file. As a result this code is replicated multiple times in the linked binary (by the number of object files in a program) and each copy of this code is called at programs startup. This negatively affects both code size and startup time. It is sufficient to have only one copy of OpenMP registration code and call it only once at startup.

Attached patch changes clang OpenMP code generation to create a COMDAT group for the OpenMP registration code and associated data which forces linker to keep only one copy of this code in the binary. Registration routine serves as a key for this COMDAT group. Visibility of the OpenMP registration routine is set to “hidden” to avoid this symbol to be preempted if it is defined in more than one component in a process (for example both executable and a shared library which executable depends on may have its own copy of initialization routine, and in such case we do not want shared library’s symbol to be preempted by executable’s symbol).

Diff Detail

Repository
rL LLVM

Event Timeline

sdmitriev created this revision.May 24 2017, 11:08 AM
ABataev accepted this revision.May 26 2017, 6:30 AM
ABataev added a subscriber: cfe-commits.

LG

This revision is now accepted and ready to land.May 26 2017, 6:31 AM

I do not have commit access yet, so I cannot commit this patch myself. Can you please check it in for me?

This revision was automatically updated to reflect the committed changes.
grokos edited edge metadata.May 26 2017, 8:04 PM

I committed the patch. Thanks for submitting it!