[PATCH] D122987: [OpenMP] Make offloading sections have the SHF_EXCLUDE flag
Joseph Huber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 14 07:51:11 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG11f47b791f96: [OpenMP] Make offloading sections have the SHF_EXCLUDE flag (authored by jhuber6).
Changed prior to commit:
https://reviews.llvm.org/D122987?vs=422552&id=422868#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122987/new/
https://reviews.llvm.org/D122987
Files:
llvm/include/llvm/MC/SectionKind.h
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/test/CodeGen/X86/offload_sections.ll
Index: llvm/test/CodeGen/X86/offload_sections.ll
===================================================================
--- llvm/test/CodeGen/X86/offload_sections.ll
+++ llvm/test/CodeGen/X86/offload_sections.ll
@@ -1,6 +1,8 @@
-; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefix=CHECK-ELF
+; RUN: llc < %s -mtriple=x86_64-win32-gnu | FileCheck %s --check-prefix=CHECK-COFF
- at llvm.embedded.object = hidden constant [1 x i8] c"\00", section ".llvm.offloading.dummy"
+ at llvm.embedded.object = private constant [1 x i8] c"\00", section ".llvm.offloading"
@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,""
+; CHECK-ELF: .section .llvm.offloading,"e"
+; CHECK-COFF: .section .llvm.offloading,"dr"
Index: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -446,10 +446,12 @@
/*AddSegmentInfo=*/false) ||
Name == getInstrProfSectionName(IPSK_covfun, Triple::ELF,
/*AddSegmentInfo=*/false) ||
- Name == ".llvmbc" || Name == ".llvmcmd" ||
- Name.startswith(".llvm.offloading."))
+ Name == ".llvmbc" || Name == ".llvmcmd")
return SectionKind::getMetadata();
+ if (Name.startswith(".llvm.offloading"))
+ return SectionKind::getExclude();
+
if (Name.empty() || Name[0] != '.') return K;
// Default implementation based on some magic section names.
@@ -508,9 +510,12 @@
static unsigned getELFSectionFlags(SectionKind K) {
unsigned Flags = 0;
- if (!K.isMetadata())
+ if (!K.isMetadata() && !K.isExclude())
Flags |= ELF::SHF_ALLOC;
+ if (K.isExclude())
+ Flags |= ELF::SHF_EXCLUDE;
+
if (K.isText())
Flags |= ELF::SHF_EXECINSTR;
@@ -1534,6 +1539,9 @@
if (K.isMetadata())
Flags |=
COFF::IMAGE_SCN_MEM_DISCARDABLE;
+ else if (K.isExclude())
+ Flags |=
+ COFF::IMAGE_SCN_LNK_REMOVE | COFF::IMAGE_SCN_MEM_DISCARDABLE;
else if (K.isText())
Flags |=
COFF::IMAGE_SCN_MEM_EXECUTE |
Index: llvm/include/llvm/MC/SectionKind.h
===================================================================
--- llvm/include/llvm/MC/SectionKind.h
+++ llvm/include/llvm/MC/SectionKind.h
@@ -24,6 +24,10 @@
/// Metadata - Debug info sections or other metadata.
Metadata,
+ /// Exclude - This section will be excluded from the final executable or
+ /// shared library. Only valid for ELF / COFF targets.
+ Exclude,
+
/// Text - Text section, used for functions and other executable code.
Text,
@@ -118,6 +122,8 @@
bool isMetadata() const { return K == Metadata; }
+ bool isExclude() const { return K == Exclude; }
+
bool isText() const { return K == Text || K == ExecuteOnly; }
bool isExecuteOnly() const { return K == ExecuteOnly; }
@@ -180,6 +186,7 @@
public:
static SectionKind getMetadata() { return get(Metadata); }
+ static SectionKind getExclude() { return get(Exclude); }
static SectionKind getText() { return get(Text); }
static SectionKind getExecuteOnly() { return get(ExecuteOnly); }
static SectionKind getReadOnly() { return get(ReadOnly); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122987.422868.patch
Type: text/x-patch
Size: 3500 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220414/935373cf/attachment.bin>
More information about the llvm-commits
mailing list