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 llvm-svn: 348922
42 lines
1.5 KiB
C++
42 lines
1.5 KiB
C++
//===-- AMDGPUHSATargetObjectFile.cpp - AMDGPU Object Files ---------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "AMDGPUTargetObjectFile.h"
|
|
#include "AMDGPU.h"
|
|
#include "AMDGPUTargetMachine.h"
|
|
#include "Utils/AMDGPUBaseInfo.h"
|
|
#include "llvm/BinaryFormat/ELF.h"
|
|
#include "llvm/MC/MCContext.h"
|
|
#include "llvm/MC/MCSectionELF.h"
|
|
|
|
using namespace llvm;
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// Generic Object File
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal(
|
|
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
|
|
if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GO) &&
|
|
AMDGPU::shouldEmitConstantsToTextSection(TM.getTargetTriple()))
|
|
return TextSection;
|
|
|
|
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);
|
|
}
|