This is an archive of the discontinued LLVM Phabricator instance.

[TargetLoweringObjectFileImpl] Make .llvmbc and .llvmcmd non-SHF_ALLOC
ClosedPublic

Authored by MaskRay on Aug 21 2020, 2:49 PM.

Details

Summary

There are two ways .llvmbc can be produced:

  • clang -c -fembed-bitcode=all (which also produces .llvmcmd)
  • LTO backend: ld.lld -mllvm -lto-embed-bitcode or -plugin-opt=-lto-embed-bitcode

.llvmbc and .llvmcmd have the SHF_ALLOC flag, so they can be dropped by
--gc-sections.

This patch sets SectionKind::Metadata to drop the SHF_ALLOC flag. This
is conceptually correct: the two sections are not part of the process
image, so SHF_ALLOC is not appropriate.

test/LTO/X86/embed-bitcode.ll: changed llvm-objcopy -O binary --only-section to
llvm-objcopy --dump-section. -O binary does not dump non-SHF_ALLOC sections.

Diff Detail

Event Timeline

MaskRay created this revision.Aug 21 2020, 2:49 PM
MaskRay requested review of this revision.Aug 21 2020, 2:49 PM
mtrofin edited reviewers, added: steven_wu, abdulras; removed: mtrofin.Aug 21 2020, 3:17 PM
mtrofin added a subscriber: mtrofin.
MaskRay edited reviewers, added: compnerd; removed: abdulras.Aug 21 2020, 6:36 PM
This revision is now accepted and ready to land.Aug 25 2020, 1:22 PM
MaskRay updated this revision to Diff 287769.Aug 25 2020, 1:38 PM
MaskRay edited the summary of this revision. (Show Details)

Fix embed-bitcode.ll (use --dump-section instead) and add a note

This revision was landed with ongoing or failed builds.Aug 25 2020, 1:42 PM
This revision was automatically updated to reflect the committed changes.
nikic added a subscriber: nikic.Jul 29 2021, 3:36 AM

Could you please take a look at https://bugs.llvm.org/show_bug.cgi?id=51207, which has been caused by this change?

MaskRay added a comment.EditedJul 29 2021, 1:33 PM

Could you please take a look at https://bugs.llvm.org/show_bug.cgi?id=51207, which has been caused by this change?

Not very related to this patch.

The Rust code abuses a previous LLVM behavior which was changed by D100944 (similar to D72194).
I will make a comment to https://bugs.llvm.org/show_bug.cgi?id=51207