[PATCH] D120275: [OpenMP] Ensure offloading sections do not have SHF_ALLOC flag

Joseph Huber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 21 11:53:03 PST 2022


jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, JonChesterfield.
Herald added subscribers: pengfei, guansong, hiraditya, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120275

Files:
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/test/CodeGen/X86/offload_sections.ll


Index: llvm/test/CodeGen/X86/offload_sections.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/offload_sections.ll
@@ -0,0 +1,6 @@
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+
+ at llvm.embedded.object = hidden constant [1 x i8] c"\00", section ".llvm.offloading.dummy"
+ at 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,""
Index: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -446,7 +446,8 @@
                                       /*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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120275.410357.patch
Type: text/x-patch
Size: 1253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220221/3caeedf1/attachment.bin>


More information about the llvm-commits mailing list