This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Make offloading sections have the SHF_EXCLUDE flag
ClosedPublic

Authored by jhuber6 on Apr 2 2022, 3:07 PM.

Details

Summary

Offloading sections can be embedded in the host during codegen via a
section. This section was originally marked as metadata to prevent it
from being loaded, but these sections are completely unused at runtime
so the linker should automatically drop them from the final executable
or shard library. This flag adds support for the SHF_EXCLUDE flag in
target lowering and uses it.

Diff Detail

Event Timeline

jhuber6 created this revision.Apr 2 2022, 3:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 2 2022, 3:07 PM
jhuber6 requested review of this revision.Apr 2 2022, 3:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 2 2022, 3:07 PM

I think we need tests for coff and elf for the MC part, should be existing ones for the other flags. Ideal fit for the openmp sectiy, good find. Inclined to ignore the formatting warnings on old code.

jhuber6 updated this revision to Diff 420636.Apr 5 2022, 2:27 PM
jhuber6 edited the summary of this revision. (Show Details)

Adding COFF test.

JonChesterfield accepted this revision.Apr 13 2022, 7:40 AM

Thanks for the extra test lines!

This revision is now accepted and ready to land.Apr 13 2022, 7:40 AM
MaskRay accepted this revision.Apr 13 2022, 9:29 AM
MaskRay added inline comments.
llvm/include/llvm/MC/SectionKind.h
27

https://llvm.org/docs/CodingStandards.html#doxygen-use-in-documentation-comments "Don’t duplicate function or class name at the beginning of the comment."

It may help to add "(ELF specific)".

jhuber6 added inline comments.Apr 13 2022, 9:31 AM
llvm/include/llvm/MC/SectionKind.h
27

Yes, this only works for COFF and ELF so that should probably be documented. As for the style I'm just keeping it consistent with what's already here. I could make a follow-up patch to clean it but I figured it would add unnecessary noise to this one.

MaskRay added inline comments.Apr 13 2022, 9:32 AM
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
452

getMetadata() | getExclude().

SHF_EXCLUDE is orthogonal to SHF_ALLOC.

jhuber6 updated this revision to Diff 422552.Apr 13 2022, 10:09 AM

Making suggested changes.

jhuber6 marked an inline comment as done.Apr 13 2022, 10:10 AM
MaskRay accepted this revision.Apr 13 2022, 2:59 PM
MaskRay added inline comments.
llvm/test/CodeGen/X86/offload_sections.ll
7–8

Remove -DAG. There is no other line for testing.

If there is other stuff after "e", check that. If there isn't any, append {{$}}

This revision was landed with ongoing or failed builds.Apr 14 2022, 7:51 AM
This revision was automatically updated to reflect the committed changes.