[llvm] r267034 - [Hexagon] Expand handling of the small-data/bss section
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 21 11:56:46 PDT 2016
Author: kparzysz
Date: Thu Apr 21 13:56:45 2016
New Revision: 267034
URL: http://llvm.org/viewvc/llvm-project?rev=267034&view=rev
Log:
[Hexagon] Expand handling of the small-data/bss section
Added:
llvm/trunk/test/CodeGen/Hexagon/sdata-array.ll
llvm/trunk/test/CodeGen/Hexagon/sdata-basic.ll
llvm/trunk/test/CodeGen/Hexagon/section_7275.ll
Modified:
llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp
llvm/trunk/lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp
llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h
llvm/trunk/test/CodeGen/Hexagon/extload-combine.ll
llvm/trunk/test/CodeGen/Hexagon/static.ll
Modified: llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp?rev=267034&r1=267033&r2=267034&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonISelLowering.cpp Thu Apr 21 13:56:45 2016
@@ -1507,7 +1507,7 @@ HexagonTargetLowering::LowerGLOBALADDRES
if (RM == Reloc::Static) {
SDValue GA = DAG.getTargetGlobalAddress(GV, dl, PtrVT, Offset);
- if (HLOF.IsGlobalInSmallSection(GV, HTM))
+ if (HLOF.isGlobalInSmallSection(GV, HTM))
return DAG.getNode(HexagonISD::CONST32_GP, dl, PtrVT, GA);
return DAG.getNode(HexagonISD::CONST32, dl, PtrVT, GA);
}
Modified: llvm/trunk/lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp?rev=267034&r1=267033&r2=267034&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp Thu Apr 21 13:56:45 2016
@@ -72,7 +72,7 @@ bool HexagonSplitConst32AndConst64::runO
const HexagonTargetObjectFile &TLOF =
*static_cast<const HexagonTargetObjectFile *>(
Fn.getTarget().getObjFileLowering());
- if (TLOF.IsSmallDataEnabled())
+ if (TLOF.isSmallDataEnabled())
return true;
const TargetInstrInfo *TII = Fn.getSubtarget().getInstrInfo();
Modified: llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp?rev=267034&r1=267033&r2=267034&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp Thu Apr 21 13:56:45 2016
@@ -1,4 +1,4 @@
-//===-- HexagonTargetObjectFile.cpp - Hexagon asm properties --------------===//
+//===-- HexagonTargetObjectFile.cpp ---------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,10 +10,10 @@
// This file contains the declarations of the HexagonTargetAsmInfo properties.
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "hexagon-sdata"
-#include "HexagonTargetObjectFile.h"
-#include "HexagonSubtarget.h"
#include "HexagonTargetMachine.h"
+#include "HexagonTargetObjectFile.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
@@ -24,75 +24,368 @@
using namespace llvm;
-static cl::opt<int> SmallDataThreshold("hexagon-small-data-threshold",
- cl::init(8), cl::Hidden,
- cl::desc("The maximum size of an object in the sdata section"));
+static cl::opt<unsigned> SmallDataThreshold("hexagon-small-data-threshold",
+ cl::init(8), cl::Hidden,
+ cl::desc("The maximum size of an object in the sdata section"));
+
+static cl::opt<bool> NoSmallDataSorting("mno-sort-sda", cl::init(false),
+ cl::Hidden, cl::desc("Disable small data sections sorting"));
+
+static cl::opt<bool> StaticsInSData("hexagon-statics-in-small-data",
+ cl::init(false), cl::Hidden, cl::ZeroOrMore,
+ cl::desc("Allow static variables in .sdata"));
+
+static cl::opt<bool> TraceGVPlacement("trace-gv-placement",
+ cl::Hidden, cl::init(false),
+ cl::desc("Trace global value placement"));
+
+// TraceGVPlacement controls messages for all builds. For builds with assertions
+// (debug or release), messages are also controlled by the usual debug flags
+// (e.g. -debug and -debug-only=globallayout)
+#define TRACE_TO(s, X) s << X
+#ifdef NDEBUG
+#define TRACE(X) do { if (TraceGVPlacement) { TRACE_TO(errs(), X); } } while (0)
+#else
+#define TRACE(X) \
+ do { \
+ if (TraceGVPlacement) { TRACE_TO(errs(), X); } \
+ else { DEBUG( TRACE_TO(dbgs(), X) ); } \
+ } while (0)
+#endif
+
+// Returns true if the section name is such that the symbol will be put
+// in a small data section.
+// For instance, global variables with section attributes such as ".sdata"
+// ".sdata.*", ".sbss", and ".sbss.*" will go into small data.
+static bool isSmallDataSection(StringRef Sec) {
+ // sectionName is either ".sdata" or ".sbss". Looking for an exact match
+ // obviates the need for checks for section names such as ".sdatafoo".
+ if (Sec.equals(".sdata") || Sec.equals(".sbss") || Sec.equals(".scommon"))
+ return true;
+ // If either ".sdata." or ".sbss." is a substring of the section name
+ // then put the symbol in small data.
+ return Sec.find(".sdata.") != StringRef::npos ||
+ Sec.find(".sbss.") != StringRef::npos ||
+ Sec.find(".scommon.") != StringRef::npos;
+}
+
+
+static const char *getSectionSuffixForSize(unsigned Size) {
+ switch (Size) {
+ default:
+ return "";
+ case 1:
+ return ".1";
+ case 2:
+ return ".2";
+ case 4:
+ return ".4";
+ case 8:
+ return ".8";
+ }
+}
void HexagonTargetObjectFile::Initialize(MCContext &Ctx,
- const TargetMachine &TM) {
+ const TargetMachine &TM) {
TargetLoweringObjectFileELF::Initialize(Ctx, TM);
InitializeELF(TM.Options.UseInitArray);
- SmallDataSection = getContext().getELFSection(
- ".sdata", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
- SmallBSSSection = getContext().getELFSection(".sbss", ELF::SHT_NOBITS,
- ELF::SHF_WRITE | ELF::SHF_ALLOC);
+ SmallDataSection =
+ getContext().getELFSection(".sdata", ELF::SHT_PROGBITS,
+ ELF::SHF_WRITE | ELF::SHF_ALLOC |
+ ELF::SHF_HEX_GPREL);
+ SmallBSSSection =
+ getContext().getELFSection(".sbss", ELF::SHT_NOBITS,
+ ELF::SHF_WRITE | ELF::SHF_ALLOC |
+ ELF::SHF_HEX_GPREL);
}
-// sdata/sbss support taken largely from the MIPS Backend.
-static bool IsInSmallSection(uint64_t Size) {
- return Size > 0 && Size <= (uint64_t)SmallDataThreshold;
+
+MCSection *HexagonTargetObjectFile::SelectSectionForGlobal(
+ const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
+ 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 " : "" )
+ << (Kind.isCommon() ? "kind_common " : "" )
+ << (Kind.isBSS() ? "kind_bss " : "" )
+ << (Kind.isBSSLocal() ? "kind_bss_local " : "" ));
+
+ if (isGlobalInSmallSection(GV, TM))
+ return selectSmallSectionForGlobal(GV, Kind, Mang, TM);
+
+ if (Kind.isCommon()) {
+ // This is purely for LTO+Linker Script because commons don't really have a
+ // section. However, the BitcodeSectionWriter pass will query for the
+ // sections of commons (and the linker expects us to know their section) so
+ // we'll return one here.
+ return BSSSection;
+ }
+
+ TRACE("default_ELF_section\n");
+ // Otherwise, we work the same as ELF.
+ return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind,
+ Mang, TM);
}
-bool HexagonTargetObjectFile::IsSmallDataEnabled () const {
- return SmallDataThreshold > 0;
+
+MCSection *HexagonTargetObjectFile::getExplicitSectionGlobal(
+ const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
+ 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 " : "" )
+ << (Kind.isCommon() ? "kind_common " : "" )
+ << (Kind.isBSS() ? "kind_bss " : "" )
+ << (Kind.isBSSLocal() ? "kind_bss_local " : "" ));
+
+ if (GV->hasSection()) {
+ StringRef Section = GV->getSection();
+ if (Section.find(".access.text.group") != StringRef::npos)
+ return getContext().getELFSection(GV->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,
+ ELF::SHF_WRITE | ELF::SHF_ALLOC);
+ }
+
+ if (isGlobalInSmallSection(GV, TM))
+ return selectSmallSectionForGlobal(GV, Kind, Mang, TM);
+
+ // Otherwise, we work the same as ELF.
+ TRACE("default_ELF_section\n");
+ return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GV, Kind,
+ Mang, TM);
}
-/// IsGlobalInSmallSection - Return true if this global value should be
-/// placed into small data/bss section.
-bool HexagonTargetObjectFile::IsGlobalInSmallSection(const GlobalValue *GV,
- const TargetMachine &TM) const {
- // If the primary definition of this global value is outside the current
- // translation unit or the global value is available for inspection but not
- // emission, then do nothing.
- if (GV->isDeclaration() || GV->hasAvailableExternallyLinkage())
- return false;
-
- // Otherwise, Check if GV should be in sdata/sbss, when normally it would end
- // up in getKindForGlobal(GV, TM).
- return IsGlobalInSmallSection(GV, TM, getKindForGlobal(GV, TM));
-}
-
-/// IsGlobalInSmallSection - Return true if this global value should be
-/// placed into small data/bss section.
-bool HexagonTargetObjectFile::
-IsGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM,
- SectionKind Kind) const {
+
+/// Return true if this global value should be placed into small data/bss
+/// section.
+bool HexagonTargetObjectFile::isGlobalInSmallSection(const GlobalValue *GV,
+ const TargetMachine &TM) const {
// Only global variables, not functions.
- const GlobalVariable *GVA = dyn_cast<GlobalVariable>(GV);
- if (!GVA)
+ DEBUG(dbgs() << "Checking if value is in small-data, -G"
+ << SmallDataThreshold << ": \"" << GV->getName() << "\": ");
+ const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
+ if (!GVar) {
+ DEBUG(dbgs() << "no, not a global variable\n");
+ return false;
+ }
+
+ // Globals with external linkage that have an original section set must be
+ // emitted to that section, regardless of whether we would put them into
+ // small data or not. This is how we can support mixing -G0/-G8 in LTO.
+ if (GVar->hasSection()) {
+ bool IsSmall = isSmallDataSection(GVar->getSection());
+ DEBUG(dbgs() << (IsSmall ? "yes" : "no") << ", has section: "
+ << GVar->getSection() << '\n');
+ return IsSmall;
+ }
+
+ if (GVar->isConstant()) {
+ DEBUG(dbgs() << "no, is a constant\n");
+ return false;
+ }
+
+ bool IsLocal = GVar->hasLocalLinkage();
+ if (!StaticsInSData && IsLocal) {
+ DEBUG(dbgs() << "no, is static\n");
+ return false;
+ }
+
+ Type *GType = GVar->getType();
+ if (PointerType *PT = dyn_cast<PointerType>(GType))
+ GType = PT->getElementType();
+
+ if (isa<ArrayType>(GType)) {
+ DEBUG(dbgs() << "no, is an array\n");
return false;
+ }
+
+ // If the type is a struct with no body provided, treat is conservatively.
+ // There cannot be actual definitions of object of such a type in this CU
+ // (only references), so assuming that they are not in sdata is safe. If
+ // these objects end up in the sdata, the references will still be valid.
+ if (StructType *ST = dyn_cast<StructType>(GType)) {
+ if (ST->isOpaque()) {
+ DEBUG(dbgs() << "no, has opaque type\n");
+ return false;
+ }
+ }
+
+ unsigned Size = GVar->getParent()->getDataLayout().getTypeAllocSize(GType);
+ if (Size == 0) {
+ DEBUG(dbgs() << "no, has size 0\n");
+ return false;
+ }
+ if (Size > SmallDataThreshold) {
+ DEBUG(dbgs() << "no, size exceeds sdata threshold: " << Size << '\n');
+ return false;
+ }
+
+ DEBUG(dbgs() << "yes\n");
+ return true;
+}
+
+
+bool HexagonTargetObjectFile::isSmallDataEnabled() const {
+ return SmallDataThreshold > 0;
+}
+
- if (Kind.isBSS() || Kind.isData() || Kind.isCommon()) {
- Type *Ty = GV->getValueType();
- return IsInSmallSection(
- GV->getParent()->getDataLayout().getTypeAllocSize(Ty));
+unsigned HexagonTargetObjectFile::getSmallDataSize() const {
+ return SmallDataThreshold;
+}
+
+
+/// Descends any type down to "elementary" components,
+/// discovering the smallest addressable one.
+/// If zero is returned, declaration will not be modified.
+unsigned HexagonTargetObjectFile::getSmallestAddressableSize(const Type *Ty,
+ const GlobalValue *GV, const TargetMachine &TM) const {
+ // Assign the smallest element access size to the highest
+ // value which assembler can handle.
+ unsigned SmallestElement = 8;
+
+ if (!Ty)
+ return 0;
+ switch (Ty->getTypeID()) {
+ case Type::StructTyID: {
+ const StructType *STy = cast<const StructType>(Ty);
+ for (auto &E : STy->elements()) {
+ unsigned AtomicSize = getSmallestAddressableSize(E, GV, TM);
+ if (AtomicSize < SmallestElement)
+ SmallestElement = AtomicSize;
+ }
+ return (STy->getNumElements() == 0) ? 0 : SmallestElement;
+ }
+ case Type::ArrayTyID: {
+ const ArrayType *ATy = cast<const ArrayType>(Ty);
+ return getSmallestAddressableSize(ATy->getElementType(), GV, TM);
+ }
+ case Type::VectorTyID: {
+ const VectorType *PTy = cast<const VectorType>(Ty);
+ return getSmallestAddressableSize(PTy->getElementType(), GV, TM);
+ }
+ case Type::PointerTyID:
+ case Type::HalfTyID:
+ case Type::FloatTyID:
+ case Type::DoubleTyID:
+ case Type::IntegerTyID: {
+ const DataLayout &DL = GV->getParent()->getDataLayout();
+ // It is unfortunate that DL's function take non-const Type*.
+ return DL.getTypeAllocSize(const_cast<Type*>(Ty));
+ }
+ case Type::FunctionTyID:
+ case Type::VoidTyID:
+ case Type::X86_FP80TyID:
+ case Type::FP128TyID:
+ case Type::PPC_FP128TyID:
+ case Type::LabelTyID:
+ case Type::MetadataTyID:
+ case Type::X86_MMXTyID:
+ case Type::TokenTyID:
+ return 0;
}
- return false;
+ return 0;
}
-MCSection *
-HexagonTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
- SectionKind Kind, Mangler &Mang,
- const TargetMachine &TM) const {
+MCSection *HexagonTargetObjectFile::selectSmallSectionForGlobal(
+ const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
+ const TargetMachine &TM) const {
+ const Type *GTy = GV->getType()->getElementType();
+ unsigned Size = getSmallestAddressableSize(GTy, GV, 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.
+ bool EmitUniquedSection = TM.getDataSections();
+
+ TRACE("Small data. Size(" << Size << ")");
// Handle Small Section classification here.
- if (Kind.isBSS() && IsGlobalInSmallSection(GV, TM, Kind))
- return SmallBSSSection;
- if (Kind.isData() && IsGlobalInSmallSection(GV, TM, Kind))
- return SmallDataSection;
+ if (Kind.isBSS() || Kind.isBSSLocal()) {
+ // If -mno-sort-sda is not set, find out smallest accessible entity in
+ // declaration and add it to the section name string.
+ // Note. It does not track the actual usage of the value, only its de-
+ // claration. Also, compiler adds explicit pad fields to some struct
+ // declarations - they are currently counted towards smallest addres-
+ // sable entity.
+ if (NoSmallDataSorting) {
+ TRACE(" default sbss\n");
+ return SmallBSSSection;
+ }
+
+ StringRef Prefix(".sbss");
+ SmallString<128> Name(Prefix);
+ Name.append(getSectionSuffixForSize(Size));
+
+ if (EmitUniquedSection) {
+ Name.append(".");
+ Name.append(GV->getName());
+ }
+ TRACE(" unique sbss(" << Name << ")\n");
+ return getContext().getELFSection(Name.str(), ELF::SHT_NOBITS,
+ ELF::SHF_WRITE | ELF::SHF_ALLOC | ELF::SHF_HEX_GPREL);
+ }
+
+ if (Kind.isCommon()) {
+ // This is purely for LTO+Linker Script because commons don't really have a
+ // section. However, the BitcodeSectionWriter pass will query for the
+ // sections of commons (and the linker expects us to know their section) so
+ // we'll return one here.
+ if (NoSmallDataSorting)
+ return BSSSection;
+
+ Twine Name = Twine(".scommon") + getSectionSuffixForSize(Size);
+ TRACE(" small COMMON (" << Name << ")\n");
+
+ return getContext().getELFSection(Name.str(), ELF::SHT_NOBITS,
+ ELF::SHF_WRITE | ELF::SHF_ALLOC |
+ ELF::SHF_HEX_GPREL);
+ }
+
+ // We could have changed sdata object to a constant... in this
+ // case the Kind could be wrong for it.
+ if (Kind.isMergeableConst()) {
+ TRACE(" const_object_as_data ");
+ const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
+ if (GVar->hasSection() && isSmallDataSection(GVar->getSection()))
+ Kind = SectionKind::getData();
+ }
+
+ if (Kind.isData()) {
+ if (NoSmallDataSorting) {
+ TRACE(" default sdata\n");
+ return SmallDataSection;
+ }
+
+ StringRef Prefix(".sdata");
+ SmallString<128> Name(Prefix);
+ Name.append(getSectionSuffixForSize(Size));
+
+ if (EmitUniquedSection) {
+ Name.append(".");
+ Name.append(GV->getName());
+ }
+ TRACE(" unique sdata(" << Name << ")\n");
+ return getContext().getELFSection(Name.str(), ELF::SHT_PROGBITS,
+ ELF::SHF_WRITE | ELF::SHF_ALLOC | ELF::SHF_HEX_GPREL);
+ }
+ TRACE("default ELF section\n");
// Otherwise, we work the same as ELF.
- return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, Mang,TM);
+ return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind,
+ Mang, TM);
}
Modified: llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h?rev=267034&r1=267033&r2=267034&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h Thu Apr 21 13:56:45 2016
@@ -1,4 +1,4 @@
-//===-- HexagonTargetAsmInfo.h - Hexagon asm properties --------*- C++ -*--===//
+//===-- HexagonTargetObjectFile.h -----------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,24 +16,31 @@
namespace llvm {
class HexagonTargetObjectFile : public TargetLoweringObjectFileELF {
- MCSectionELF *SmallDataSection;
- MCSectionELF *SmallBSSSection;
-
public:
void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
- /// IsGlobalInSmallSection - 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,
- const TargetMachine &TM) const;
-
- bool IsSmallDataEnabled () const;
MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
- Mangler &Mang,
- const TargetMachine &TM) const override;
+ Mangler &Mang, const TargetMachine &TM) const override;
+
+ MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
+ Mangler &Mang, const TargetMachine &TM) const override;
+
+ bool isGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM)
+ const;
+
+ bool isSmallDataEnabled() const;
+
+ unsigned getSmallDataSize() const;
+
+ private:
+ MCSectionELF *SmallDataSection;
+ MCSectionELF *SmallBSSSection;
+
+ unsigned getSmallestAddressableSize(const Type *Ty, const GlobalValue *GV,
+ const TargetMachine &TM) const;
+
+ MCSection *selectSmallSectionForGlobal(const GlobalValue *GV,
+ SectionKind Kind, Mangler &Mang, const TargetMachine &TM) const;
};
} // namespace llvm
Modified: llvm/trunk/test/CodeGen/Hexagon/extload-combine.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Hexagon/extload-combine.ll?rev=267034&r1=267033&r2=267034&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/Hexagon/extload-combine.ll (original)
+++ llvm/trunk/test/CodeGen/Hexagon/extload-combine.ll Thu Apr 21 13:56:45 2016
@@ -1,4 +1,4 @@
-; RUN: llc -march=hexagon -mcpu=hexagonv4 -O3 -disable-hsdr < %s | FileCheck %s
+; RUN: llc -march=hexagon -hexagon-small-data-threshold=0 -disable-hsdr < %s | FileCheck %s
; Check that the combine/stxw instructions are being generated.
; In case of combine one of the operand should be 0 and another should be
; the output of absolute addressing load instruction.
Added: llvm/trunk/test/CodeGen/Hexagon/sdata-array.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Hexagon/sdata-array.ll?rev=267034&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Hexagon/sdata-array.ll (added)
+++ llvm/trunk/test/CodeGen/Hexagon/sdata-array.ll Thu Apr 21 13:56:45 2016
@@ -0,0 +1,13 @@
+; RUN: llc -march=hexagon < %s | FileCheck %s
+
+; No arrays in sdata.
+; CHECK: memb(##foo)
+
+ at foo = common global [4 x i8] zeroinitializer, align 1
+
+define void @set() nounwind {
+entry:
+ store i8 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @foo, i32 0, i32 0), align 1
+ ret void
+}
+
Added: llvm/trunk/test/CodeGen/Hexagon/sdata-basic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Hexagon/sdata-basic.ll?rev=267034&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Hexagon/sdata-basic.ll (added)
+++ llvm/trunk/test/CodeGen/Hexagon/sdata-basic.ll Thu Apr 21 13:56:45 2016
@@ -0,0 +1,16 @@
+; RUN: llc -march=hexagon -O2 < %s | FileCheck %s
+; CHECK-NOT: ##var
+target datalayout = "e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-i1:32:32-f64:64:64-f32:32:32-v64:64:64-v32:32:32-a0:0-n16:32"
+target triple = "hexagon"
+
+ at var = external global i32
+
+define i32 @foo() nounwind readonly {
+entry:
+ %0 = load i32, i32* @var, align 4, !tbaa !0
+ ret i32 %0
+}
+
+!0 = !{!"int", !1}
+!1 = !{!"omnipotent char", !2}
+!2 = !{!"Simple C/C++ TBAA"}
Added: llvm/trunk/test/CodeGen/Hexagon/section_7275.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Hexagon/section_7275.ll?rev=267034&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Hexagon/section_7275.ll (added)
+++ llvm/trunk/test/CodeGen/Hexagon/section_7275.ll Thu Apr 21 13:56:45 2016
@@ -0,0 +1,54 @@
+; The reason for the bug was that when deciding if a global
+; variable can be part of sdata, we were wrongly ignoring
+; the presence of any section specified for the variable
+; using the section attribute. If such a section is specified,
+; and that section is not sdata*/sbss* then the variable
+; cannot use GPREL addressing, i.e. memw(#variablename).
+
+; RUN: llc -march=hexagon < %s | FileCheck %s
+; CHECK-LABEL: foo
+; CHECK-DAG: memw(##b)
+; CHECK-DAG: memw(#d)
+; CHECK-DAG: memw(##g)
+; CHECK-DAG: memw(#h)
+; CHECK-DAG: memw(#f)
+; CHECK-DAG: memw(##e)
+; CHECK-DAG: memw(#a)
+; CHECK-DAG: memw(#c)
+; CHECK-LABEL: bar
+; CHECK: memw(##b)
+
+ at b = global i32 0, section ".data.section", align 4
+ at a = common global i32 0, align 4
+ at d = global i32 0, section ".sbss", align 4
+ at c = global i32 0, section ".sdata", align 4
+ at f = global i32 0, section ".sbss.4", align 4
+ at e = global i32 0, section ".sdatafoo", align 4
+ at h = global i32 0, section ".sdata.4", align 4
+ at g = global i32 0, section ".sbssfoo", align 4
+
+define void @foo() nounwind {
+entry:
+ %0 = load i32, i32* @b, align 4
+ store i32 %0, i32* @a, align 4
+ %1 = load i32, i32* @d, align 4
+ store i32 %1, i32* @c, align 4
+ %2 = load i32, i32* @f, align 4
+ store i32 %2, i32* @e, align 4
+ %3 = load i32, i32* @h, align 4
+ store i32 %3, i32* @g, align 4
+ ret void
+}
+
+define void @bar() nounwind section ".function.section" {
+entry:
+ %0 = load i32, i32* @a, align 4
+ store i32 %0, i32* @b, align 4
+ ret void
+}
+
+define i32 @main() nounwind readnone {
+entry:
+ ret i32 0
+}
+
Modified: llvm/trunk/test/CodeGen/Hexagon/static.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Hexagon/static.ll?rev=267034&r1=267033&r2=267034&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/Hexagon/static.ll (original)
+++ llvm/trunk/test/CodeGen/Hexagon/static.ll Thu Apr 21 13:56:45 2016
@@ -1,12 +1,12 @@
-; RUN: llc -march=hexagon -mcpu=hexagonv4 -disable-dfa-sched -disable-hexagon-misched < %s | FileCheck %s
+; RUN: llc -march=hexagon < %s | FileCheck %s
@num = external global i32
@acc = external global i32
@val = external global i32
-; CHECK: memw(##num)
-; CHECK: memw(##acc)
-; CHECK: memw(##val)
+; CHECK-DAG: memw(#num)
+; CHECK-DAG: memw(#acc)
+; CHECK-DAG: memw(#val)
define void @foo() nounwind {
entry:
More information about the llvm-commits
mailing list