[llvm] r348922 - [AMDGPU] Set metadata access for explicit section
Piotr Sobczak via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 12 03:20:05 PST 2018
Author: piotr
Date: Wed Dec 12 03:20:04 2018
New Revision: 348922
URL: http://llvm.org/viewvc/llvm-project?rev=348922&view=rev
Log:
[AMDGPU] Set metadata access for explicit section
Summary:
This patch provides a means to set Metadata section kind
for a global variable, if its explicit section name is
prefixed with ".AMDGPU.metadata."
This could be useful to make the global variable go to
an ELF section without any section flags set.
Reviewers: dstuttard, tpr, kzhuravl, nhaehnle, t-tye
Reviewed By: dstuttard, kzhuravl
Subscribers: llvm-commits, arsenm, jvesely, wdng, yaxunl, t-tye
Differential Revision: https://reviews.llvm.org/D55267
Added:
llvm/trunk/test/CodeGen/AMDGPU/elf.metadata.ll
Modified:
llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp?rev=348922&r1=348921&r2=348922&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp Wed Dec 12 03:20:04 2018
@@ -29,3 +29,13 @@ MCSection *AMDGPUTargetObjectFile::Selec
return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
}
+
+MCSection *AMDGPUTargetObjectFile::getExplicitSectionGlobal(
+ const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const {
+ // Set metadata access for the explicit section
+ StringRef SectionName = GO->getSection();
+ if (SectionName.startswith(".AMDGPU.metadata."))
+ SK = SectionKind::getMetadata();
+
+ return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM);
+}
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h?rev=348922&r1=348921&r2=348922&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h Wed Dec 12 03:20:04 2018
@@ -26,6 +26,8 @@ class AMDGPUTargetObjectFile : public Ta
public:
MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
const TargetMachine &TM) const override;
+ MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
+ const TargetMachine &TM) const override;
};
} // end namespace llvm
Added: llvm/trunk/test/CodeGen/AMDGPU/elf.metadata.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/elf.metadata.ll?rev=348922&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/elf.metadata.ll (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/elf.metadata.ll Wed Dec 12 03:20:04 2018
@@ -0,0 +1,56 @@
+; RUN: llc < %s -march=amdgcn -mcpu=fiji -filetype=obj | llvm-readobj -symbols -s -sd - | FileCheck %s
+
+; CHECK: Section {
+; CHECK: Name: .AMDGPU.metadata.info_1
+; CHECK: Type: SHT_PROGBITS (0x1)
+; CHECK: Flags [ (0x0)
+; CHECK: Size: 16
+; CHECK: SectionData (
+; CHECK: 0000: 414D4431 414D4431 414D4431 414D4431 |AMD1AMD1AMD1AMD1|
+; CHECK: )
+; CHECK: }
+
+; CHECK: Section {
+; CHECK: Name: .AMDGPU.metadata.info_2
+; CHECK: Type: SHT_PROGBITS (0x1)
+; CHECK: Flags [ (0x0)
+; CHECK: Size: 16
+; CHECK: SectionData (
+; CHECK: 0000: 414D4432 414D4432 414D4432 414D4432 |AMD2AMD2AMD2AMD2|
+; CHECK: )
+; CHECK: }
+
+; CHECK: Section {
+; CHECK: Name: .AMDGPU.metadata.info_3
+; CHECK: Type: SHT_PROGBITS (0x1)
+; CHECK: Flags [ (0x0)
+; CHECK: Size: 16
+; CHECK: SectionData (
+; CHECK: 0000: 414D4433 414D4433 414D4433 414D4433 |AMD3AMD3AMD3AMD3|
+; CHECK: )
+; CHECK: }
+
+; CHECK: Symbol {
+; CHECK: Name: metadata_info_var_1
+; CHECK: Size: 16
+; CHECK: Binding: Local
+; CHECK: Section: .AMDGPU.metadata.info_1
+; CHECK: }
+
+; CHECK: Symbol {
+; CHECK: Name: metadata_info_var_2
+; CHECK: Size: 16
+; CHECK: Binding: Global
+; CHECK: Section: .AMDGPU.metadata.info_2
+; CHECK: }
+
+; CHECK: Symbol {
+; CHECK: Name: metadata_info_var_3
+; CHECK: Size: 16
+; CHECK: Binding: Global
+; CHECK: Section: .AMDGPU.metadata.info_3
+; CHECK: }
+
+ at metadata_info_var_1 = internal global [4 x i32][i32 826559809, i32 826559809, i32 826559809, i32 826559809], align 1, section ".AMDGPU.metadata.info_1"
+ at metadata_info_var_2 = constant [4 x i32][i32 843337025, i32 843337025, i32 843337025, i32 843337025], align 1, section ".AMDGPU.metadata.info_2"
+ at metadata_info_var_3 = global [4 x i32][i32 860114241, i32 860114241, i32 860114241, i32 860114241], align 1, section ".AMDGPU.metadata.info_3"
More information about the llvm-commits
mailing list