This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Do not split functions with attr "implicit-section-name".
ClosedPublic

Authored by snehasish on Apr 21 2021, 4:42 PM.

Details

Summary

The #pragma clang section can be used at a coarse granularity to specify
the section used for bss/data/text/rodata for global objects. When split
functions is enabled, the function may be split into two parts violating
user expectations.

Reference:
https://clang.llvm.org/docs/LanguageExtensions.html#specifying-section-names-for-global-objects-pragma-clang-section

Diff Detail

Event Timeline

snehasish created this revision.Apr 21 2021, 4:42 PM
snehasish requested review of this revision.Apr 21 2021, 4:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2021, 4:42 PM
rahmanl accepted this revision.Apr 21 2021, 5:20 PM
rahmanl added inline comments.
llvm/lib/CodeGen/MachineFunctionSplitter.cpp
104–105

nit: Can you use hasSection() here to be more consistent with TargetLoweringObjectFile.cpp?

This revision is now accepted and ready to land.Apr 21 2021, 5:20 PM
snehasish updated this revision to Diff 339429.Apr 21 2021, 5:27 PM

Use hasSection() in the condition.

snehasish marked an inline comment as done.Apr 21 2021, 5:28 PM
snehasish updated this revision to Diff 339458.Apr 21 2021, 8:56 PM

Revert hasSection() since it is not semantically equivalent to getSection().empty().

snehasish added inline comments.Apr 21 2021, 9:46 PM
llvm/lib/CodeGen/MachineFunctionSplitter.cpp
104–105

Looks like this is not consistent even though the documentation suggests that they should be equivalent, so I'll revert it for now.

This revision was landed with ongoing or failed builds.Apr 21 2021, 9:54 PM
This revision was automatically updated to reflect the committed changes.