[llvm] 456ffd7 - [OpenMP] Ensure offloading sections do not have SHF_ALLOC flag
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 21 18:35:26 PST 2022
Author: Joseph Huber
Date: 2022-02-21T21:35:17-05:00
New Revision: 456ffd7a225f908ca61d747be21439f6182ea40c
URL: https://github.com/llvm/llvm-project/commit/456ffd7a225f908ca61d747be21439f6182ea40c
DIFF: https://github.com/llvm/llvm-project/commit/456ffd7a225f908ca61d747be21439f6182ea40c.diff
LOG: [OpenMP] Ensure offloading sections do not have SHF_ALLOC flag
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
Added:
llvm/test/CodeGen/X86/offload_sections.ll
Modified:
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 0892c74a7a24b..348470bd7687d 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -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;
diff --git a/llvm/test/CodeGen/X86/offload_sections.ll b/llvm/test/CodeGen/X86/offload_sections.ll
new file mode 100644
index 0000000000000..dcd6dcb7cf3fc
--- /dev/null
+++ b/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,""
More information about the llvm-commits
mailing list