summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorNick Desaulniers <ndesaulniers@google.com>2018-10-12 16:35:44 +0000
committerNick Desaulniers <ndesaulniers@google.com>2018-10-12 16:35:44 +0000
commit47bab69a2ecfaa4f4f89609e162914ca5c1d63f0 (patch)
treee9ea36baea0bda02ec10e11ed7890be5dce850e4 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent9f169afab22b7334739c9de0ea1a1ab1ee0c357e (diff)
downloadbcm5719-llvm-47bab69a2ecfaa4f4f89609e162914ca5c1d63f0.tar.gz
bcm5719-llvm-47bab69a2ecfaa4f4f89609e162914ca5c1d63f0.zip
[MC][ELF] fix newly added test
Summary: Reland of - r344197 "[MC][ELF] compute entity size for explicit sections" - r344206 "[MC][ELF] Fix section_mergeable_size.ll" after being reverted in r344278 due to build breakages from not specifying a target triple. Move test from test/CodeGen/Generic/ to test/MC/ELF/. Add explicit target triple so we don't try to run this test on non ELF targets. Reported: https://reviews.llvm.org/D53056#1261707 Reviewers: fhahn, rnk, espindola, NoQ Reviewed By: fhahn, rnk Subscribers: NoQ, MaskRay, rengolin, emaste, arichardson, llvm-commits, pirama, srhines Differential Revision: https://reviews.llvm.org/D53146 llvm-svn: 344360
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index f6882c40531..b046cd81d6c 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -506,6 +506,30 @@ static const MCSymbolELF *getAssociatedSymbol(const GlobalObject *GO,
return OtherGO ? dyn_cast<MCSymbolELF>(TM.getSymbol(OtherGO)) : nullptr;
}
+static unsigned getEntrySizeForKind(SectionKind Kind) {
+ if (Kind.isMergeable1ByteCString())
+ return 1;
+ else if (Kind.isMergeable2ByteCString())
+ return 2;
+ else if (Kind.isMergeable4ByteCString())
+ return 4;
+ else if (Kind.isMergeableConst4())
+ return 4;
+ else if (Kind.isMergeableConst8())
+ return 8;
+ else if (Kind.isMergeableConst16())
+ return 16;
+ else if (Kind.isMergeableConst32())
+ return 32;
+ else {
+ // We shouldn't have mergeable C strings or mergeable constants that we
+ // didn't handle above.
+ assert(!Kind.isMergeableCString() && "unknown string width");
+ assert(!Kind.isMergeableConst() && "unknown data width");
+ return 0;
+ }
+}
+
MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
StringRef SectionName = GO->getSection();
@@ -550,7 +574,7 @@ MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal(
MCSectionELF *Section = getContext().getELFSection(
SectionName, getELFSectionType(SectionName, Kind), Flags,
- /*EntrySize=*/0, Group, UniqueID, AssociatedSymbol);
+ getEntrySizeForKind(Kind), Group, UniqueID, AssociatedSymbol);
// Make sure that we did not get some other section with incompatible sh_link.
// This should not be possible due to UniqueID code above.
assert(Section->getAssociatedSymbol() == AssociatedSymbol &&
@@ -577,30 +601,6 @@ static StringRef getSectionPrefixForGlobal(SectionKind Kind) {
return ".data.rel.ro";
}
-static unsigned getEntrySizeForKind(SectionKind Kind) {
- if (Kind.isMergeable1ByteCString())
- return 1;
- else if (Kind.isMergeable2ByteCString())
- return 2;
- else if (Kind.isMergeable4ByteCString())
- return 4;
- else if (Kind.isMergeableConst4())
- return 4;
- else if (Kind.isMergeableConst8())
- return 8;
- else if (Kind.isMergeableConst16())
- return 16;
- else if (Kind.isMergeableConst32())
- return 32;
- else {
- // We shouldn't have mergeable C strings or mergeable constants that we
- // didn't handle above.
- assert(!Kind.isMergeableCString() && "unknown string width");
- assert(!Kind.isMergeableConst() && "unknown data width");
- return 0;
- }
-}
-
static MCSectionELF *selectELFSectionForGlobal(
MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang,
const TargetMachine &TM, bool EmitUniqueSection, unsigned Flags,
OpenPOWER on IntegriCloud