This is an archive of the discontinued LLVM Phabricator instance.

[CallGraphSection] Introduce CGSectionFuncComdatCreator pass
AbandonedPublic

Authored by necipfazil on Jul 13 2021, 10:30 AM.

Details

Summary

Create comdats for functions whose symbols will be referenced from the
call graph section. These comdats are used to create the call graph
sections, so that, the sections can get discarded by the linker if the
functions get removed.

Original RFC: https://lists.llvm.org/pipermail/llvm-dev/2021-June/151044.html
Updated RFC: https://lists.llvm.org/pipermail/llvm-dev/2021-July/151739.html

Diff Detail

Event Timeline

necipfazil created this revision.Jul 13 2021, 10:30 AM
necipfazil requested review of this revision.Jul 13 2021, 10:30 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 13 2021, 10:30 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
lattner resigned from this revision.Jul 13 2021, 11:40 AM

Are comdats needed? Can we get proper dead stripping with just SHF_LINK_ORDER?

@MaskRay recently updated the documentation for associated metadata to imply that our symbol doesn't need to share a comdat with its associated function when the function doesn't have a comdat.

Also, @MaskRay: Can adding comdats like this change the final code in the fully-linked binary?

necipfazil abandoned this revision.Jul 17 2021, 7:46 PM

Are comdats needed? Can we get proper dead stripping with just SHF_LINK_ORDER?

It looks like we can. I am abandoning this revision. I will shortly push the changes to related revisions for not using comdats.

@MaskRay recently updated the documentation for associated metadata to imply that our symbol doesn't need to share a comdat with its associated function when the function doesn't have a comdat.

Also, @MaskRay: Can adding comdats like this change the final code in the fully-linked binary?

MaskRay added inline comments.Jul 18 2021, 2:05 PM
clang/lib/CodeGen/BackendUtil.cpp
1420
llvm/lib/Transforms/Utils/CGSectionFuncComdatCreator.cpp
64

clang-format prefers /*IgnoreCallbackUses=*/true

91

delete braces

llvm/test/Transforms/Util/create-function-comdats.ll
1

This should be within a call-graph-section specific directory.

Use test/Instrumentation/InstrProfiling/comdat.ll as a reference