[llvm] r285006 - Target: Change various section classifiers in TargetLoweringObjectFile to take a GlobalObject.
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 25 06:00:47 PDT 2016
Thanks!
On 24 October 2016 at 15:23, Peter Collingbourne via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: pcc
> Date: Mon Oct 24 14:23:39 2016
> New Revision: 285006
>
> URL: http://llvm.org/viewvc/llvm-project?rev=285006&view=rev
> Log:
> Target: Change various section classifiers in TargetLoweringObjectFile to take a GlobalObject.
>
> These functions are about classifying a global which will actually be
> emitted, so it does not make sense for them to take a GlobalValue which may
> for example be an alias.
>
> Change the Mach-O object writer and the Hexagon, Lanai and MIPS backends to
> look through aliases before using TargetLoweringObjectFile interfaces. These
> are functional changes but all appear to be bug fixes.
>
> Differential Revision: https://reviews.llvm.org/D25917
>
> Modified:
> llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
> llvm/trunk/include/llvm/IR/GlobalValue.h
> llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
> llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
> llvm/trunk/lib/IR/Globals.cpp
> llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp
> llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h
> llvm/trunk/lib/Target/AVR/AVRTargetObjectFile.cpp
> llvm/trunk/lib/Target/AVR/AVRTargetObjectFile.h
> llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp
> llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
> llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h
> llvm/trunk/lib/Target/Lanai/LanaiISelLowering.cpp
> llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp
> llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.h
> llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp
> llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp
> llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h
> llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
> llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h
> llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp
> llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h
> llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
> llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp
> llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h
>
> Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h Mon Oct 24 14:23:39 2016
> @@ -53,10 +53,10 @@ public:
> const Constant *C,
> unsigned &Align) const override;
>
> - MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
>
> - MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
>
> MCSection *getSectionForJumpTable(const Function &F,
> @@ -103,10 +103,10 @@ public:
> ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
> const TargetMachine &TM) const override;
>
> - MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
>
> - MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
>
> MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
> @@ -144,10 +144,10 @@ public:
> ~TargetLoweringObjectFileCOFF() override {}
>
> void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
> - MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
>
> - MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
>
> void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
>
> Modified: llvm/trunk/include/llvm/IR/GlobalValue.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GlobalValue.h?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/IR/GlobalValue.h (original)
> +++ llvm/trunk/include/llvm/IR/GlobalValue.h Mon Oct 24 14:23:39 2016
> @@ -26,6 +26,7 @@
> namespace llvm {
>
> class Comdat;
> +class GlobalObject;
> class PointerType;
> class Module;
>
> @@ -492,6 +493,11 @@ public:
> // increased.
> bool canIncreaseAlignment() const;
>
> + const GlobalObject *getBaseObject() const {
> + return const_cast<GlobalValue *>(this)->getBaseObject();
> + }
> + GlobalObject *getBaseObject();
> +
> /// This method unlinks 'this' from the containing module, but does not delete
> /// it.
> virtual void removeFromParent() = 0;
>
> Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original)
> +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Mon Oct 24 14:23:39 2016
> @@ -86,21 +86,21 @@ public:
>
> /// Classify the specified global variable into a set of target independent
> /// categories embodied in SectionKind.
> - static SectionKind getKindForGlobal(const GlobalValue *GV,
> + static SectionKind getKindForGlobal(const GlobalObject *GO,
> const TargetMachine &TM);
>
> /// This method computes the appropriate section to emit the specified global
> /// variable or function definition. This should not be passed external (or
> /// available externally) globals.
> - MCSection *SectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *SectionForGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const;
>
> /// This method computes the appropriate section to emit the specified global
> /// variable or function definition. This should not be passed external (or
> /// available externally) globals.
> - MCSection *SectionForGlobal(const GlobalValue *GV,
> + MCSection *SectionForGlobal(const GlobalObject *GO,
> const TargetMachine &TM) const {
> - return SectionForGlobal(GV, getKindForGlobal(GV, TM), TM);
> + return SectionForGlobal(GO, getKindForGlobal(GO, TM), TM);
> }
>
> virtual void getNameWithPrefix(SmallVectorImpl<char> &OutName,
> @@ -115,9 +115,9 @@ public:
>
> /// Targets should implement this method to assign a section to globals with
> /// an explicit section specfied. The implementation of this method can
> - /// assume that GV->hasSection() is true.
> + /// assume that GO->hasSection() is true.
> virtual MCSection *
> - getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
> + getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const = 0;
>
> /// Return an MCExpr to use for a reference to the specified global variable
> @@ -187,7 +187,7 @@ public:
> const GlobalValue *GV) const {}
>
> protected:
> - virtual MCSection *SelectSectionForGlobal(const GlobalValue *GV,
> + virtual MCSection *SelectSectionForGlobal(const GlobalObject *GO,
> SectionKind Kind,
> const TargetMachine &TM) const = 0;
> };
>
> Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
> +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Mon Oct 24 14:23:39 2016
> @@ -209,15 +209,15 @@ static const Comdat *getELFComdat(const
> }
>
> MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> - StringRef SectionName = GV->getSection();
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> + StringRef SectionName = GO->getSection();
>
> // Infer section flags from the section name if we can.
> Kind = getELFKindForNamedSection(SectionName, Kind);
>
> StringRef Group = "";
> unsigned Flags = getELFSectionFlags(Kind);
> - if (const Comdat *C = getELFComdat(GV)) {
> + if (const Comdat *C = getELFComdat(GO)) {
> Group = C->getName();
> Flags |= ELF::SHF_GROUP;
> }
> @@ -246,7 +246,7 @@ static StringRef getSectionPrefixForGlob
> }
>
> static MCSectionELF *
> -selectELFSectionForGlobal(MCContext &Ctx, const GlobalValue *GV,
> +selectELFSectionForGlobal(MCContext &Ctx, const GlobalObject *GO,
> SectionKind Kind, Mangler &Mang,
> const TargetMachine &TM, bool EmitUniqueSection,
> unsigned Flags, unsigned *NextUniqueID) {
> @@ -274,7 +274,7 @@ selectELFSectionForGlobal(MCContext &Ctx
> }
>
> StringRef Group = "";
> - if (const Comdat *C = getELFComdat(GV)) {
> + if (const Comdat *C = getELFComdat(GO)) {
> Flags |= ELF::SHF_GROUP;
> Group = C->getName();
> }
> @@ -285,8 +285,8 @@ selectELFSectionForGlobal(MCContext &Ctx
> // We also need alignment here.
> // FIXME: this is getting the alignment of the character, not the
> // alignment of the global!
> - unsigned Align = GV->getParent()->getDataLayout().getPreferredAlignment(
> - cast<GlobalVariable>(GV));
> + unsigned Align = GO->getParent()->getDataLayout().getPreferredAlignment(
> + cast<GlobalVariable>(GO));
>
> std::string SizeSpec = ".rodata.str" + utostr(EntrySize) + ".";
> Name = SizeSpec + utostr(Align);
> @@ -297,7 +297,7 @@ selectELFSectionForGlobal(MCContext &Ctx
> Name = getSectionPrefixForGlobal(Kind);
> }
>
> - if (const Function *F = dyn_cast<Function>(GV)) {
> + if (const auto *F = dyn_cast<Function>(GO)) {
> const auto &OptionalPrefix = F->getSectionPrefix();
> if (OptionalPrefix)
> Name += *OptionalPrefix;
> @@ -305,7 +305,7 @@ selectELFSectionForGlobal(MCContext &Ctx
>
> if (EmitUniqueSection && UniqueSectionNames) {
> Name.push_back('.');
> - TM.getNameWithPrefix(Name, GV, Mang, true);
> + TM.getNameWithPrefix(Name, GO, Mang, true);
> }
> unsigned UniqueID = MCContext::GenericSectionID;
> if (EmitUniqueSection && !UniqueSectionNames) {
> @@ -317,7 +317,7 @@ selectELFSectionForGlobal(MCContext &Ctx
> }
>
> MCSection *TargetLoweringObjectFileELF::SelectSectionForGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> unsigned Flags = getELFSectionFlags(Kind);
>
> // If we have -ffunction-section or -fdata-section then we should emit the
> @@ -329,9 +329,9 @@ MCSection *TargetLoweringObjectFileELF::
> else
> EmitUniqueSection = TM.getDataSections();
> }
> - EmitUniqueSection |= GV->hasComdat();
> + EmitUniqueSection |= GO->hasComdat();
>
> - return selectELFSectionForGlobal(getContext(), GV, Kind, getMangler(), TM,
> + return selectELFSectionForGlobal(getContext(), GO, Kind, getMangler(), TM,
> EmitUniqueSection, Flags, &NextUniqueID);
> }
>
> @@ -572,22 +572,22 @@ static void checkMachOComdat(const Globa
> }
>
> MCSection *TargetLoweringObjectFileMachO::getExplicitSectionGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> // Parse the section specifier and create it if valid.
> StringRef Segment, Section;
> unsigned TAA = 0, StubSize = 0;
> bool TAAParsed;
>
> - checkMachOComdat(GV);
> + checkMachOComdat(GO);
>
> std::string ErrorCode =
> - MCSectionMachO::ParseSectionSpecifier(GV->getSection(), Segment, Section,
> + MCSectionMachO::ParseSectionSpecifier(GO->getSection(), Segment, Section,
> TAA, TAAParsed, StubSize);
> if (!ErrorCode.empty()) {
> // If invalid, report the error with report_fatal_error.
> - report_fatal_error("Global variable '" + GV->getName() +
> + report_fatal_error("Global variable '" + GO->getName() +
> "' has an invalid section specifier '" +
> - GV->getSection() + "': " + ErrorCode + ".");
> + GO->getSection() + "': " + ErrorCode + ".");
> }
>
> // Get the section.
> @@ -604,7 +604,7 @@ MCSection *TargetLoweringObjectFileMachO
> // to reject it here.
> if (S->getTypeAndAttributes() != TAA || S->getStubSize() != StubSize) {
> // If invalid, report the error with report_fatal_error.
> - report_fatal_error("Global variable '" + GV->getName() +
> + report_fatal_error("Global variable '" + GO->getName() +
> "' section type or attributes does not match previous"
> " section specifier");
> }
> @@ -613,19 +613,19 @@ MCSection *TargetLoweringObjectFileMachO
> }
>
> MCSection *TargetLoweringObjectFileMachO::SelectSectionForGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> - checkMachOComdat(GV);
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> + checkMachOComdat(GO);
>
> // Handle thread local data.
> if (Kind.isThreadBSS()) return TLSBSSSection;
> if (Kind.isThreadData()) return TLSDataSection;
>
> if (Kind.isText())
> - return GV->isWeakForLinker() ? TextCoalSection : TextSection;
> + return GO->isWeakForLinker() ? TextCoalSection : TextSection;
>
> // If this is weak/linkonce, put this in a coalescable section, either in text
> // or data depending on if it is writable.
> - if (GV->isWeakForLinker()) {
> + if (GO->isWeakForLinker()) {
> if (Kind.isReadOnly())
> return ConstTextCoalSection;
> return DataCoalSection;
> @@ -633,21 +633,21 @@ MCSection *TargetLoweringObjectFileMachO
>
> // FIXME: Alignment check should be handled by section classifier.
> if (Kind.isMergeable1ByteCString() &&
> - GV->getParent()->getDataLayout().getPreferredAlignment(
> - cast<GlobalVariable>(GV)) < 32)
> + GO->getParent()->getDataLayout().getPreferredAlignment(
> + cast<GlobalVariable>(GO)) < 32)
> return CStringSection;
>
> // Do not put 16-bit arrays in the UString section if they have an
> // externally visible label, this runs into issues with certain linker
> // versions.
> - if (Kind.isMergeable2ByteCString() && !GV->hasExternalLinkage() &&
> - GV->getParent()->getDataLayout().getPreferredAlignment(
> - cast<GlobalVariable>(GV)) < 32)
> + if (Kind.isMergeable2ByteCString() && !GO->hasExternalLinkage() &&
> + GO->getParent()->getDataLayout().getPreferredAlignment(
> + cast<GlobalVariable>(GO)) < 32)
> return UStringSection;
>
> // With MachO only variables whose corresponding symbol starts with 'l' or
> // 'L' can be merged, so we only try merging GVs with private linkage.
> - if (GV->hasPrivateLinkage() && Kind.isMergeableConst()) {
> + if (GO->hasPrivateLinkage() && Kind.isMergeableConst()) {
> if (Kind.isMergeableConst4())
> return FourByteConstantSection;
> if (Kind.isMergeableConst8())
> @@ -821,10 +821,13 @@ static bool canUsePrivateLabel(const MCA
> void TargetLoweringObjectFileMachO::getNameWithPrefix(
> SmallVectorImpl<char> &OutName, const GlobalValue *GV,
> const TargetMachine &TM) const {
> - SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM);
> - const MCSection *TheSection = SectionForGlobal(GV, GVKind, TM);
> - bool CannotUsePrivateLabel =
> - !canUsePrivateLabel(*TM.getMCAsmInfo(), *TheSection);
> + bool CannotUsePrivateLabel = true;
> + if (auto *GO = GV->getBaseObject()) {
> + SectionKind GOKind = TargetLoweringObjectFile::getKindForGlobal(GO, TM);
> + const MCSection *TheSection = SectionForGlobal(GO, GOKind, TM);
> + CannotUsePrivateLabel =
> + !canUsePrivateLabel(*TM.getMCAsmInfo(), *TheSection);
> + }
> getMangler().getNameWithPrefix(OutName, GV, CannotUsePrivateLabel);
> }
>
> @@ -912,18 +915,18 @@ static int getSelectionForCOFF(const Glo
> }
>
> MCSection *TargetLoweringObjectFileCOFF::getExplicitSectionGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> int Selection = 0;
> unsigned Characteristics = getCOFFSectionFlags(Kind, TM);
> - StringRef Name = GV->getSection();
> + StringRef Name = GO->getSection();
> StringRef COMDATSymName = "";
> - if (GV->hasComdat()) {
> - Selection = getSelectionForCOFF(GV);
> + if (GO->hasComdat()) {
> + Selection = getSelectionForCOFF(GO);
> const GlobalValue *ComdatGV;
> if (Selection == COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE)
> - ComdatGV = getComdatGVForCOFF(GV);
> + ComdatGV = getComdatGVForCOFF(GO);
> else
> - ComdatGV = GV;
> + ComdatGV = GO;
>
> if (!ComdatGV->hasPrivateLinkage()) {
> MCSymbol *Sym = TM.getSymbol(ComdatGV, getMangler());
> @@ -951,7 +954,7 @@ static const char *getCOFFSectionNameFor
> }
>
> MCSection *TargetLoweringObjectFileCOFF::SelectSectionForGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> // If we have -ffunction-sections then we should emit the global value to a
> // uniqued section specifically for it.
> bool EmitUniquedSection;
> @@ -960,19 +963,19 @@ MCSection *TargetLoweringObjectFileCOFF:
> else
> EmitUniquedSection = TM.getDataSections();
>
> - if ((EmitUniquedSection && !Kind.isCommon()) || GV->hasComdat()) {
> + if ((EmitUniquedSection && !Kind.isCommon()) || GO->hasComdat()) {
> const char *Name = getCOFFSectionNameForUniqueGlobal(Kind);
> unsigned Characteristics = getCOFFSectionFlags(Kind, TM);
>
> Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
> - int Selection = getSelectionForCOFF(GV);
> + int Selection = getSelectionForCOFF(GO);
> if (!Selection)
> Selection = COFF::IMAGE_COMDAT_SELECT_NODUPLICATES;
> const GlobalValue *ComdatGV;
> - if (GV->hasComdat())
> - ComdatGV = getComdatGVForCOFF(GV);
> + if (GO->hasComdat())
> + ComdatGV = getComdatGVForCOFF(GO);
> else
> - ComdatGV = GV;
> + ComdatGV = GO;
>
> unsigned UniqueID = MCContext::GenericSectionID;
> if (EmitUniquedSection)
> @@ -985,7 +988,7 @@ MCSection *TargetLoweringObjectFileCOFF:
> COMDATSymName, Selection, UniqueID);
> } else {
> SmallString<256> TmpData;
> - getMangler().getNameWithPrefix(TmpData, GV, /*CannotUsePrivateLabel=*/true);
> + getMangler().getNameWithPrefix(TmpData, GO, /*CannotUsePrivateLabel=*/true);
> return getContext().getCOFFSection(Name, Characteristics, Kind, TmpData,
> Selection, UniqueID);
> }
>
> Modified: llvm/trunk/lib/IR/Globals.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Globals.cpp?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/IR/Globals.cpp (original)
> +++ llvm/trunk/lib/IR/Globals.cpp Mon Oct 24 14:23:39 2016
> @@ -213,6 +213,14 @@ bool GlobalValue::canIncreaseAlignment()
> return true;
> }
>
> +GlobalObject *GlobalValue::getBaseObject() {
> + if (auto *GO = dyn_cast<GlobalObject>(this))
> + return GO;
> + if (auto *GA = dyn_cast<GlobalAlias>(this))
> + return GA->getBaseObject();
> + return nullptr;
> +}
> +
> //===----------------------------------------------------------------------===//
> // GlobalVariable Implementation
> //===----------------------------------------------------------------------===//
>
> Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp Mon Oct 24 14:23:39 2016
> @@ -21,10 +21,10 @@ using namespace llvm;
> //===----------------------------------------------------------------------===//
>
> MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> - if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GV) &&
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> + if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GO) &&
> AMDGPU::shouldEmitConstantsToTextSection(TM.getTargetTriple()))
> return TextSection;
>
> - return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, TM);
> + return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
> }
>
> Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h Mon Oct 24 14:23:39 2016
> @@ -23,7 +23,7 @@ namespace llvm {
>
> class AMDGPUTargetObjectFile : public TargetLoweringObjectFileELF {
> public:
> - MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
> };
>
>
> Modified: llvm/trunk/lib/Target/AVR/AVRTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/AVRTargetObjectFile.cpp?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AVR/AVRTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/AVR/AVRTargetObjectFile.cpp Mon Oct 24 14:23:39 2016
> @@ -26,16 +26,16 @@ void AVRTargetObjectFile::Initialize(MCC
> }
>
> MCSection *
> -AVRTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
> +AVRTargetObjectFile::SelectSectionForGlobal(const GlobalObject *GO,
> SectionKind Kind,
> const TargetMachine &TM) const {
> // Global values in flash memory are placed in the progmem.data section
> // unless they already have a user assigned section.
> - if (AVR::isProgramMemoryAddress(GV) && !GV->hasSection())
> + if (AVR::isProgramMemoryAddress(GO) && !GO->hasSection())
> return ProgmemDataSection;
>
> // Otherwise, we work the same way as ELF.
> - return Base::SelectSectionForGlobal(GV, Kind, TM);
> + return Base::SelectSectionForGlobal(GO, Kind, TM);
> }
> } // end of namespace llvm
>
>
> Modified: llvm/trunk/lib/Target/AVR/AVRTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/AVRTargetObjectFile.h?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AVR/AVRTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/AVR/AVRTargetObjectFile.h Mon Oct 24 14:23:39 2016
> @@ -21,7 +21,7 @@ class AVRTargetObjectFile : public Targe
> public:
> void Initialize(MCContext &ctx, const TargetMachine &TM) override;
>
> - MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
>
> private:
>
> Modified: llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp Mon Oct 24 14:23:39 2016
> @@ -1507,7 +1507,8 @@ HexagonTargetLowering::LowerGLOBALADDRES
>
> if (RM == Reloc::Static) {
> SDValue GA = DAG.getTargetGlobalAddress(GV, dl, PtrVT, Offset);
> - if (HLOF.isGlobalInSmallSection(GV, HTM))
> + const GlobalObject *GO = GV->getBaseObject();
> + if (GO && HLOF.isGlobalInSmallSection(GO, HTM))
> return DAG.getNode(HexagonISD::CONST32_GP, dl, PtrVT, GA);
> return DAG.getNode(HexagonISD::CONST32, dl, PtrVT, GA);
> }
>
> Modified: llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp Mon Oct 24 14:23:39 2016
> @@ -101,22 +101,22 @@ void HexagonTargetObjectFile::Initialize
> }
>
> MCSection *HexagonTargetObjectFile::SelectSectionForGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> - TRACE("[SelectSectionForGlobal] GV(" << GV->getName() << ") ");
> - TRACE("input section(" << GV->getSection() << ") ");
> -
> - TRACE((GV->hasPrivateLinkage() ? "private_linkage " : "")
> - << (GV->hasLocalLinkage() ? "local_linkage " : "")
> - << (GV->hasInternalLinkage() ? "internal " : "")
> - << (GV->hasExternalLinkage() ? "external " : "")
> - << (GV->hasCommonLinkage() ? "common_linkage " : "")
> - << (GV->hasCommonLinkage() ? "common " : "" )
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> + TRACE("[SelectSectionForGlobal] GO(" << GO->getName() << ") ");
> + TRACE("input section(" << GO->getSection() << ") ");
> +
> + TRACE((GO->hasPrivateLinkage() ? "private_linkage " : "")
> + << (GO->hasLocalLinkage() ? "local_linkage " : "")
> + << (GO->hasInternalLinkage() ? "internal " : "")
> + << (GO->hasExternalLinkage() ? "external " : "")
> + << (GO->hasCommonLinkage() ? "common_linkage " : "")
> + << (GO->hasCommonLinkage() ? "common " : "" )
> << (Kind.isCommon() ? "kind_common " : "" )
> << (Kind.isBSS() ? "kind_bss " : "" )
> << (Kind.isBSSLocal() ? "kind_bss_local " : "" ));
>
> - if (isGlobalInSmallSection(GV, TM))
> - return selectSmallSectionForGlobal(GV, Kind, TM);
> + if (isGlobalInSmallSection(GO, TM))
> + return selectSmallSectionForGlobal(GO, Kind, TM);
>
> if (Kind.isCommon()) {
> // This is purely for LTO+Linker Script because commons don't really have a
> @@ -128,50 +128,50 @@ MCSection *HexagonTargetObjectFile::Sele
>
> TRACE("default_ELF_section\n");
> // Otherwise, we work the same as ELF.
> - return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, TM);
> + return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
> }
>
> MCSection *HexagonTargetObjectFile::getExplicitSectionGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> - TRACE("[getExplicitSectionGlobal] GV(" << GV->getName() << ") from("
> - << GV->getSection() << ") ");
> - TRACE((GV->hasPrivateLinkage() ? "private_linkage " : "")
> - << (GV->hasLocalLinkage() ? "local_linkage " : "")
> - << (GV->hasInternalLinkage() ? "internal " : "")
> - << (GV->hasExternalLinkage() ? "external " : "")
> - << (GV->hasCommonLinkage() ? "common_linkage " : "")
> - << (GV->hasCommonLinkage() ? "common " : "" )
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> + TRACE("[getExplicitSectionGlobal] GO(" << GO->getName() << ") from("
> + << GO->getSection() << ") ");
> + TRACE((GO->hasPrivateLinkage() ? "private_linkage " : "")
> + << (GO->hasLocalLinkage() ? "local_linkage " : "")
> + << (GO->hasInternalLinkage() ? "internal " : "")
> + << (GO->hasExternalLinkage() ? "external " : "")
> + << (GO->hasCommonLinkage() ? "common_linkage " : "")
> + << (GO->hasCommonLinkage() ? "common " : "" )
> << (Kind.isCommon() ? "kind_common " : "" )
> << (Kind.isBSS() ? "kind_bss " : "" )
> << (Kind.isBSSLocal() ? "kind_bss_local " : "" ));
>
> - if (GV->hasSection()) {
> - StringRef Section = GV->getSection();
> + if (GO->hasSection()) {
> + StringRef Section = GO->getSection();
> if (Section.find(".access.text.group") != StringRef::npos)
> - return getContext().getELFSection(GV->getSection(), ELF::SHT_PROGBITS,
> + return getContext().getELFSection(GO->getSection(), ELF::SHT_PROGBITS,
> ELF::SHF_ALLOC | ELF::SHF_EXECINSTR);
> if (Section.find(".access.data.group") != StringRef::npos)
> - return getContext().getELFSection(GV->getSection(), ELF::SHT_PROGBITS,
> + return getContext().getELFSection(GO->getSection(), ELF::SHT_PROGBITS,
> ELF::SHF_WRITE | ELF::SHF_ALLOC);
> }
>
> - if (isGlobalInSmallSection(GV, TM))
> - return selectSmallSectionForGlobal(GV, Kind, TM);
> + if (isGlobalInSmallSection(GO, TM))
> + return selectSmallSectionForGlobal(GO, Kind, TM);
>
> // Otherwise, we work the same as ELF.
> TRACE("default_ELF_section\n");
> - return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GV, Kind, TM);
> + return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, Kind, TM);
> }
>
>
> /// Return true if this global value should be placed into small data/bss
> /// section.
> -bool HexagonTargetObjectFile::isGlobalInSmallSection(const GlobalValue *GV,
> +bool HexagonTargetObjectFile::isGlobalInSmallSection(const GlobalObject *GO,
> const TargetMachine &TM) const {
> // Only global variables, not functions.
> DEBUG(dbgs() << "Checking if value is in small-data, -G"
> - << SmallDataThreshold << ": \"" << GV->getName() << "\": ");
> - const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
> + << SmallDataThreshold << ": \"" << GO->getName() << "\": ");
> + const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GO);
> if (!GVar) {
> DEBUG(dbgs() << "no, not a global variable\n");
> return false;
> @@ -297,9 +297,9 @@ unsigned HexagonTargetObjectFile::getSma
> }
>
> MCSection *HexagonTargetObjectFile::selectSmallSectionForGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> - const Type *GTy = GV->getType()->getElementType();
> - unsigned Size = getSmallestAddressableSize(GTy, GV, TM);
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> + const Type *GTy = GO->getType()->getElementType();
> + unsigned Size = getSmallestAddressableSize(GTy, GO, TM);
>
> // If we have -ffunction-section or -fdata-section then we should emit the
> // global value to a unique section specifically for it... even for sdata.
> @@ -325,7 +325,7 @@ MCSection *HexagonTargetObjectFile::sele
>
> if (EmitUniquedSection) {
> Name.append(".");
> - Name.append(GV->getName());
> + Name.append(GO->getName());
> }
> TRACE(" unique sbss(" << Name << ")\n");
> return getContext().getELFSection(Name.str(), ELF::SHT_NOBITS,
> @@ -352,7 +352,7 @@ MCSection *HexagonTargetObjectFile::sele
> // case the Kind could be wrong for it.
> if (Kind.isMergeableConst()) {
> TRACE(" const_object_as_data ");
> - const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
> + const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GO);
> if (GVar->hasSection() && isSmallDataSection(GVar->getSection()))
> Kind = SectionKind::getData();
> }
> @@ -369,7 +369,7 @@ MCSection *HexagonTargetObjectFile::sele
>
> if (EmitUniquedSection) {
> Name.append(".");
> - Name.append(GV->getName());
> + Name.append(GO->getName());
> }
> TRACE(" unique sdata(" << Name << ")\n");
> return getContext().getELFSection(Name.str(), ELF::SHT_PROGBITS,
> @@ -378,5 +378,5 @@ MCSection *HexagonTargetObjectFile::sele
>
> TRACE("default ELF section\n");
> // Otherwise, we work the same as ELF.
> - return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, TM);
> + return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
> }
>
> Modified: llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h Mon Oct 24 14:23:39 2016
> @@ -19,14 +19,15 @@ namespace llvm {
> public:
> void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
>
> - MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
>
> - MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *getExplicitSectionGlobal(const GlobalObject *GO,
> + SectionKind Kind,
> const TargetMachine &TM) const override;
>
> - bool isGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM)
> - const;
> + bool isGlobalInSmallSection(const GlobalObject *GO,
> + const TargetMachine &TM) const;
>
> bool isSmallDataEnabled() const;
>
> @@ -39,7 +40,7 @@ namespace llvm {
> unsigned getSmallestAddressableSize(const Type *Ty, const GlobalValue *GV,
> const TargetMachine &TM) const;
>
> - MCSection *selectSmallSectionForGlobal(const GlobalValue *GV,
> + MCSection *selectSmallSectionForGlobal(const GlobalObject *GO,
> SectionKind Kind,
> const TargetMachine &TM) const;
> };
>
> Modified: llvm/trunk/lib/Target/Lanai/LanaiISelLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Lanai/LanaiISelLowering.cpp?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Lanai/LanaiISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/Lanai/LanaiISelLowering.cpp Mon Oct 24 14:23:39 2016
> @@ -1167,8 +1167,9 @@ SDValue LanaiTargetLowering::LowerGlobal
>
> // If the code model is small or global variable will be placed in the small
> // section, then assume address will fit in 21-bits.
> + const GlobalObject *GO = GV->getBaseObject();
> if (getTargetMachine().getCodeModel() == CodeModel::Small ||
> - TLOF->isGlobalInSmallSection(GV, getTargetMachine())) {
> + (GO && TLOF->isGlobalInSmallSection(GO, getTargetMachine()))) {
> SDValue Small = DAG.getTargetGlobalAddress(
> GV, DL, getPointerTy(DAG.getDataLayout()), Offset, LanaiII::MO_NO_FLAG);
> return DAG.getNode(ISD::OR, DL, MVT::i32,
>
> Modified: llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp Mon Oct 24 14:23:39 2016
> @@ -49,22 +49,22 @@ static bool isInSmallSection(uint64_t Si
> // Return true if this global address should be placed into small data/bss
> // section.
> bool LanaiTargetObjectFile::isGlobalInSmallSection(
> - const GlobalValue *GV, const TargetMachine &TM) const {
> + const GlobalObject *GO, const TargetMachine &TM) const {
> // We first check the case where global is a declaration, because finding
> // section kind using getKindForGlobal() is only allowed for global
> // definitions.
> - if (GV->isDeclaration() || GV->hasAvailableExternallyLinkage())
> - return isGlobalInSmallSectionImpl(GV, TM);
> + if (GO->isDeclaration() || GO->hasAvailableExternallyLinkage())
> + return isGlobalInSmallSectionImpl(GO, TM);
>
> - return isGlobalInSmallSection(GV, TM, getKindForGlobal(GV, TM));
> + return isGlobalInSmallSection(GO, TM, getKindForGlobal(GO, TM));
> }
>
> // Return true if this global address should be placed into small data/bss
> // section.
> -bool LanaiTargetObjectFile::isGlobalInSmallSection(const GlobalValue *GV,
> +bool LanaiTargetObjectFile::isGlobalInSmallSection(const GlobalObject *GO,
> const TargetMachine &TM,
> SectionKind Kind) const {
> - return (isGlobalInSmallSectionImpl(GV, TM) &&
> + return (isGlobalInSmallSectionImpl(GO, TM) &&
> (Kind.isData() || Kind.isBSS() || Kind.isCommon()));
> }
>
> @@ -72,34 +72,34 @@ bool LanaiTargetObjectFile::isGlobalInSm
> // section. This method does all the work, except for checking the section
> // kind.
> bool LanaiTargetObjectFile::isGlobalInSmallSectionImpl(
> - const GlobalValue *GV, const TargetMachine & /*TM*/) const {
> + const GlobalObject *GO, const TargetMachine & /*TM*/) const {
> // Only global variables, not functions.
> - const GlobalVariable *GVA = dyn_cast<GlobalVariable>(GV);
> + const auto *GVA = dyn_cast<GlobalVariable>(GO);
> if (!GVA)
> return false;
>
> - if (GV->hasLocalLinkage())
> + if (GVA->hasLocalLinkage())
> return false;
>
> - if (((GV->hasExternalLinkage() && GV->isDeclaration()) ||
> - GV->hasCommonLinkage()))
> + if (((GVA->hasExternalLinkage() && GVA->isDeclaration()) ||
> + GVA->hasCommonLinkage()))
> return false;
>
> - Type *Ty = GV->getType()->getElementType();
> + Type *Ty = GVA->getValueType();
> return isInSmallSection(
> - GV->getParent()->getDataLayout().getTypeAllocSize(Ty));
> + GVA->getParent()->getDataLayout().getTypeAllocSize(Ty));
> }
>
> MCSection *LanaiTargetObjectFile::SelectSectionForGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> // Handle Small Section classification here.
> - if (Kind.isBSS() && isGlobalInSmallSection(GV, TM, Kind))
> + if (Kind.isBSS() && isGlobalInSmallSection(GO, TM, Kind))
> return SmallBSSSection;
> - if (Kind.isData() && isGlobalInSmallSection(GV, TM, Kind))
> + if (Kind.isData() && isGlobalInSmallSection(GO, TM, Kind))
> return SmallDataSection;
>
> // Otherwise, we work the same as ELF.
> - return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, TM);
> + return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
> }
>
> /// Return true if this constant should be placed into small data section.
>
> Modified: llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.h?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.h Mon Oct 24 14:23:39 2016
> @@ -18,19 +18,20 @@ class LanaiTargetObjectFile : public Tar
> MCSection *SmallDataSection;
> MCSection *SmallBSSSection;
>
> + bool isGlobalInSmallSection(const GlobalObject *GO, const TargetMachine &TM,
> + SectionKind Kind) const;
> + bool isGlobalInSmallSectionImpl(const GlobalObject *GO,
> + const TargetMachine &TM) const;
> +
> public:
> void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
>
> /// Return true if this global address should be placed into small data/bss
> /// section.
> - bool isGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM,
> - SectionKind Kind) const;
> - bool isGlobalInSmallSection(const GlobalValue *GV,
> + bool isGlobalInSmallSection(const GlobalObject *GO,
> const TargetMachine &TM) const;
> - bool isGlobalInSmallSectionImpl(const GlobalValue *GV,
> - const TargetMachine &TM) const;
>
> - MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
>
> /// Return true if this constant should be placed into small data section.
>
> Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Mon Oct 24 14:23:39 2016
> @@ -1772,7 +1772,8 @@ SDValue MipsTargetLowering::lowerGlobalA
> const MipsTargetObjectFile *TLOF =
> static_cast<const MipsTargetObjectFile *>(
> getTargetMachine().getObjFileLowering());
> - if (TLOF->IsGlobalInSmallSection(GV, getTargetMachine()))
> + const GlobalObject *GO = GV->getBaseObject();
> + if (GO && TLOF->IsGlobalInSmallSection(GO, getTargetMachine()))
> // %gp_rel relocation
> return getAddrGPRel(N, SDLoc(N), Ty, DAG);
>
>
> Modified: llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp Mon Oct 24 14:23:39 2016
> @@ -61,23 +61,23 @@ static bool IsInSmallSection(uint64_t Si
>
> /// Return true if this global address should be placed into small data/bss
> /// section.
> -bool MipsTargetObjectFile::
> -IsGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM) const {
> +bool MipsTargetObjectFile::IsGlobalInSmallSection(
> + const GlobalObject *GO, const TargetMachine &TM) const {
> // We first check the case where global is a declaration, because finding
> // section kind using getKindForGlobal() is only allowed for global
> // definitions.
> - if (GV->isDeclaration() || GV->hasAvailableExternallyLinkage())
> - return IsGlobalInSmallSectionImpl(GV, TM);
> + if (GO->isDeclaration() || GO->hasAvailableExternallyLinkage())
> + return IsGlobalInSmallSectionImpl(GO, TM);
>
> - return IsGlobalInSmallSection(GV, TM, getKindForGlobal(GV, TM));
> + return IsGlobalInSmallSection(GO, TM, getKindForGlobal(GO, TM));
> }
>
> /// Return true if this global address should be placed into small data/bss
> /// section.
> bool MipsTargetObjectFile::
> -IsGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM,
> +IsGlobalInSmallSection(const GlobalObject *GO, const TargetMachine &TM,
> SectionKind Kind) const {
> - return (IsGlobalInSmallSectionImpl(GV, TM) &&
> + return (IsGlobalInSmallSectionImpl(GO, TM) &&
> (Kind.isData() || Kind.isBSS() || Kind.isCommon()));
> }
>
> @@ -85,7 +85,7 @@ IsGlobalInSmallSection(const GlobalValue
> /// section. This method does all the work, except for checking the section
> /// kind.
> bool MipsTargetObjectFile::
> -IsGlobalInSmallSectionImpl(const GlobalValue *GV,
> +IsGlobalInSmallSectionImpl(const GlobalObject *GO,
> const TargetMachine &TM) const {
> const MipsSubtarget &Subtarget =
> *static_cast<const MipsTargetMachine &>(TM).getSubtargetImpl();
> @@ -95,37 +95,37 @@ IsGlobalInSmallSectionImpl(const GlobalV
> return false;
>
> // Only global variables, not functions.
> - const GlobalVariable *GVA = dyn_cast<GlobalVariable>(GV);
> + const GlobalVariable *GVA = dyn_cast<GlobalVariable>(GO);
> if (!GVA)
> return false;
>
> // Enforce -mlocal-sdata.
> - if (!LocalSData && GV->hasLocalLinkage())
> + if (!LocalSData && GVA->hasLocalLinkage())
> return false;
>
> // Enforce -mextern-sdata.
> - if (!ExternSData && ((GV->hasExternalLinkage() && GV->isDeclaration()) ||
> - GV->hasCommonLinkage()))
> + if (!ExternSData && ((GVA->hasExternalLinkage() && GVA->isDeclaration()) ||
> + GVA->hasCommonLinkage()))
> return false;
>
> - Type *Ty = GV->getValueType();
> + Type *Ty = GVA->getValueType();
> return IsInSmallSection(
> - GV->getParent()->getDataLayout().getTypeAllocSize(Ty));
> + GVA->getParent()->getDataLayout().getTypeAllocSize(Ty));
> }
>
> MCSection *MipsTargetObjectFile::SelectSectionForGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> // TODO: Could also support "weak" symbols as well with ".gnu.linkonce.s.*"
> // sections?
>
> // Handle Small Section classification here.
> - if (Kind.isBSS() && IsGlobalInSmallSection(GV, TM, Kind))
> + if (Kind.isBSS() && IsGlobalInSmallSection(GO, TM, Kind))
> return SmallBSSSection;
> - if (Kind.isData() && IsGlobalInSmallSection(GV, TM, Kind))
> + if (Kind.isData() && IsGlobalInSmallSection(GO, TM, Kind))
> return SmallDataSection;
>
> // Otherwise, we work the same as ELF.
> - return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, TM);
> + return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
> }
>
> /// Return true if this constant should be placed into small data section.
>
> Modified: llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h Mon Oct 24 14:23:39 2016
> @@ -18,20 +18,21 @@ class MipsTargetMachine;
> MCSection *SmallDataSection;
> MCSection *SmallBSSSection;
> const MipsTargetMachine *TM;
> +
> + bool IsGlobalInSmallSection(const GlobalObject *GO, const TargetMachine &TM,
> + SectionKind Kind) const;
> + bool IsGlobalInSmallSectionImpl(const GlobalObject *GO,
> + const TargetMachine &TM) const;
> public:
>
> void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
>
> /// Return true if this global address should be placed into small data/bss
> /// section.
> - bool IsGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM,
> - SectionKind Kind) const;
> - bool IsGlobalInSmallSection(const GlobalValue *GV,
> + bool IsGlobalInSmallSection(const GlobalObject *GO,
> const TargetMachine &TM) const;
> - bool IsGlobalInSmallSectionImpl(const GlobalValue *GV,
> - const TargetMachine &TM) const;
>
> - MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
>
> /// Return true if this constant should be placed into small data section.
>
> Modified: llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp Mon Oct 24 14:23:39 2016
> @@ -4598,6 +4598,6 @@ NVPTXTargetObjectFile::~NVPTXTargetObjec
> }
>
> MCSection *NVPTXTargetObjectFile::SelectSectionForGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> return getDataSection();
> }
>
> Modified: llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h Mon Oct 24 14:23:39 2016
> @@ -91,12 +91,12 @@ public:
> return ReadOnlySection;
> }
>
> - MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override {
> return DataSection;
> }
>
> - MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
> };
>
>
> Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp Mon Oct 24 14:23:39 2016
> @@ -23,7 +23,7 @@ Initialize(MCContext &Ctx, const TargetM
> }
>
> MCSection *PPC64LinuxTargetObjectFile::SelectSectionForGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> // Here override ReadOnlySection to DataRelROSection for PPC64 SVR4 ABI
> // when we have a constant that contains global relocations. This is
> // necessary because of this ABI's handling of pointers to functions in
> @@ -39,13 +39,13 @@ MCSection *PPC64LinuxTargetObjectFile::S
> // For more information, see the description of ELIMINATE_COPY_RELOCS in
> // GNU ld.
> if (Kind.isReadOnly()) {
> - const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
> + const auto *GVar = dyn_cast<GlobalVariable>(GO);
>
> if (GVar && GVar->isConstant() && GVar->getInitializer()->needsRelocation())
> Kind = SectionKind::getReadOnlyWithRel();
> }
>
> - return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, TM);
> + return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
> }
>
> const MCExpr *PPC64LinuxTargetObjectFile::
>
> Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h Mon Oct 24 14:23:39 2016
> @@ -22,7 +22,7 @@ namespace llvm {
>
> void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
>
> - MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
>
> /// \brief Describe a TLS variable address within debug info.
>
> Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Mon Oct 24 14:23:39 2016
> @@ -132,15 +132,15 @@ void TargetLoweringObjectFile::emitPerso
> /// classifies the global in a variety of ways that make various target
> /// implementations simpler. The target implementation is free to ignore this
> /// extra info of course.
> -SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV,
> +SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalObject *GO,
> const TargetMachine &TM){
> - assert(!GV->isDeclaration() && !GV->hasAvailableExternallyLinkage() &&
> + assert(!GO->isDeclaration() && !GO->hasAvailableExternallyLinkage() &&
> "Can only be used for global definitions");
>
> Reloc::Model ReloModel = TM.getRelocationModel();
>
> // Early exit - functions should be always in text sections.
> - const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
> + const auto *GVar = dyn_cast<GlobalVariable>(GO);
> if (!GVar)
> return SectionKind::getText();
>
> @@ -201,7 +201,8 @@ SectionKind TargetLoweringObjectFile::ge
> // Otherwise, just drop it into a mergable constant section. If we have
> // a section for this size, use it, otherwise use the arbitrary sized
> // mergable section.
> - switch (GV->getParent()->getDataLayout().getTypeAllocSize(C->getType())) {
> + switch (
> + GVar->getParent()->getDataLayout().getTypeAllocSize(C->getType())) {
> case 4: return SectionKind::getMergeableConst4();
> case 8: return SectionKind::getMergeableConst8();
> case 16: return SectionKind::getMergeableConst16();
> @@ -234,13 +235,13 @@ SectionKind TargetLoweringObjectFile::ge
> /// variable or function definition. This should not be passed external (or
> /// available externally) globals.
> MCSection *TargetLoweringObjectFile::SectionForGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> // Select section name.
> - if (GV->hasSection())
> - return getExplicitSectionGlobal(GV, Kind, TM);
> + if (GO->hasSection())
> + return getExplicitSectionGlobal(GO, Kind, TM);
>
> // Use default section depending on the 'type' of global
> - return SelectSectionForGlobal(GV, Kind, TM);
> + return SelectSectionForGlobal(GO, Kind, TM);
> }
>
> MCSection *TargetLoweringObjectFile::getSectionForJumpTable(
>
> Modified: llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp Mon Oct 24 14:23:39 2016
> @@ -96,8 +96,8 @@ static unsigned getXCoreSectionFlags(Sec
> }
>
> MCSection *XCoreTargetObjectFile::getExplicitSectionGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> - StringRef SectionName = GV->getSection();
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
> + StringRef SectionName = GO->getSection();
> // Infer section flags from the section name if we can.
> bool IsCPRel = SectionName.startswith(".cp.");
> if (IsCPRel && !Kind.isReadOnly())
> @@ -107,9 +107,9 @@ MCSection *XCoreTargetObjectFile::getExp
> }
>
> MCSection *XCoreTargetObjectFile::SelectSectionForGlobal(
> - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
> + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
>
> - bool UseCPRel = GV->isLocalLinkage(GV->getLinkage());
> + bool UseCPRel = GO->hasLocalLinkage();
>
> if (Kind.isText()) return TextSection;
> if (UseCPRel) {
> @@ -118,8 +118,8 @@ MCSection *XCoreTargetObjectFile::Select
> if (Kind.isMergeableConst8()) return MergeableConst8Section;
> if (Kind.isMergeableConst16()) return MergeableConst16Section;
> }
> - Type *ObjType = GV->getValueType();
> - auto &DL = GV->getParent()->getDataLayout();
> + Type *ObjType = GO->getValueType();
> + auto &DL = GO->getParent()->getDataLayout();
> if (TM.getCodeModel() == CodeModel::Small || !ObjType->isSized() ||
> DL.getTypeAllocSize(ObjType) < CodeModelLargeSize) {
> if (Kind.isReadOnly()) return UseCPRel? ReadOnlySection
>
> Modified: llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h?rev=285006&r1=285005&r2=285006&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h Mon Oct 24 14:23:39 2016
> @@ -25,10 +25,10 @@ static const unsigned CodeModelLargeSize
> public:
> void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
>
> - MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
>
> - MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> + MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const override;
>
> MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list