Skip to content

Commit

Permalink
[OpenMP] Ensure offloading sections do not have SHF_ALLOC flag
Browse files Browse the repository at this point in the history
We use offloading sections in the new Clang driver scheme to embed
device code into the host. We later use these sections to link the
device image, after which point they are completely unused and should
not be loaded into memory if they are still in the executable.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D120275
  • Loading branch information
jhuber6 committed Feb 22, 2022
1 parent 294072e commit 456ffd7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Expand Up @@ -446,7 +446,8 @@ static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K) {
/*AddSegmentInfo=*/false) ||
Name == getInstrProfSectionName(IPSK_covfun, Triple::ELF,
/*AddSegmentInfo=*/false) ||
Name == ".llvmbc" || Name == ".llvmcmd")
Name == ".llvmbc" || Name == ".llvmcmd" ||
Name.startswith(".llvm.offloading."))
return SectionKind::getMetadata();

if (Name.empty() || Name[0] != '.') return K;
Expand Down
6 changes: 6 additions & 0 deletions llvm/test/CodeGen/X86/offload_sections.ll
@@ -0,0 +1,6 @@
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s

@llvm.embedded.object = hidden constant [1 x i8] c"\00", section ".llvm.offloading.dummy"
@llvm.compiler.used = appending global [1 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @llvm.embedded.object, i32 0, i32 0)], section "llvm.metadata"

; CHECK-DAG: .section .llvm.offloading.dummy,""

0 comments on commit 456ffd7

Please sign in to comment.