mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
[Target] Use Align in TargetLoweringObjectFile::getSectionForConstant.
Differential Revision: https://reviews.llvm.org/D80363
This commit is contained in:
parent
7fa9fcec62
commit
b8040080d8
@ -53,7 +53,7 @@ public:
|
||||
/// placed in.
|
||||
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||
const Constant *C,
|
||||
unsigned &Align) const override;
|
||||
Align &Alignment) const override;
|
||||
|
||||
MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
|
||||
const TargetMachine &TM) const override;
|
||||
@ -116,7 +116,7 @@ public:
|
||||
|
||||
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||
const Constant *C,
|
||||
unsigned &Align) const override;
|
||||
Align &Alignment) const override;
|
||||
|
||||
/// The mach-o version of this method defaults to returning a stub reference.
|
||||
const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
|
||||
@ -182,7 +182,7 @@ public:
|
||||
/// information, return a section that it should be placed in.
|
||||
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||
const Constant *C,
|
||||
unsigned &Align) const override;
|
||||
Align &Alignment) const override;
|
||||
};
|
||||
|
||||
class TargetLoweringObjectFileWasm : public TargetLoweringObjectFile {
|
||||
@ -244,7 +244,7 @@ public:
|
||||
/// placed in.
|
||||
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||
const Constant *C,
|
||||
unsigned &Align) const override;
|
||||
Align &Alignment) const override;
|
||||
|
||||
static XCOFF::StorageClass getStorageClassForGlobal(const GlobalObject *GO);
|
||||
|
||||
|
@ -87,9 +87,8 @@ public:
|
||||
/// Given a constant with the SectionKind, return a section that it should be
|
||||
/// placed in.
|
||||
virtual MCSection *getSectionForConstant(const DataLayout &DL,
|
||||
SectionKind Kind,
|
||||
const Constant *C,
|
||||
unsigned &Align) const;
|
||||
SectionKind Kind, const Constant *C,
|
||||
Align &Alignment) const;
|
||||
|
||||
virtual MCSection *
|
||||
getSectionForMachineBasicBlock(const Function &F,
|
||||
|
@ -1639,10 +1639,10 @@ bool AsmPrinter::doFinalization(Module &M) {
|
||||
|
||||
// Emit __morestack address if needed for indirect calls.
|
||||
if (MMI->usesMorestackAddr()) {
|
||||
unsigned Align = 1;
|
||||
Align Alignment(1);
|
||||
MCSection *ReadOnlySection = getObjFileLowering().getSectionForConstant(
|
||||
getDataLayout(), SectionKind::getReadOnly(),
|
||||
/*C=*/nullptr, Align);
|
||||
/*C=*/nullptr, Alignment);
|
||||
OutStreamer->SwitchSection(ReadOnlySection);
|
||||
|
||||
MCSymbol *AddrSymbol =
|
||||
@ -1809,10 +1809,10 @@ namespace {
|
||||
// Keep track the alignment, constpool entries per Section.
|
||||
struct SectionCPs {
|
||||
MCSection *S;
|
||||
unsigned Alignment;
|
||||
Align Alignment;
|
||||
SmallVector<unsigned, 4> CPEs;
|
||||
|
||||
SectionCPs(MCSection *s, unsigned a) : S(s), Alignment(a) {}
|
||||
SectionCPs(MCSection *s, Align a) : S(s), Alignment(a) {}
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
@ -1831,7 +1831,7 @@ void AsmPrinter::emitConstantPool() {
|
||||
SmallVector<SectionCPs, 4> CPSections;
|
||||
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
|
||||
const MachineConstantPoolEntry &CPE = CP[i];
|
||||
unsigned Align = CPE.getAlign().value();
|
||||
Align Alignment = CPE.getAlign();
|
||||
|
||||
SectionKind Kind = CPE.getSectionKind(&getDataLayout());
|
||||
|
||||
@ -1839,8 +1839,8 @@ void AsmPrinter::emitConstantPool() {
|
||||
if (!CPE.isMachineConstantPoolEntry())
|
||||
C = CPE.Val.ConstVal;
|
||||
|
||||
MCSection *S = getObjFileLowering().getSectionForConstant(getDataLayout(),
|
||||
Kind, C, Align);
|
||||
MCSection *S = getObjFileLowering().getSectionForConstant(
|
||||
getDataLayout(), Kind, C, Alignment);
|
||||
|
||||
// The number of sections are small, just do a linear search from the
|
||||
// last section to the first.
|
||||
@ -1854,11 +1854,11 @@ void AsmPrinter::emitConstantPool() {
|
||||
}
|
||||
if (!Found) {
|
||||
SecIdx = CPSections.size();
|
||||
CPSections.push_back(SectionCPs(S, Align));
|
||||
CPSections.push_back(SectionCPs(S, Alignment));
|
||||
}
|
||||
|
||||
if (Align > CPSections[SecIdx].Alignment)
|
||||
CPSections[SecIdx].Alignment = Align;
|
||||
if (Alignment > CPSections[SecIdx].Alignment)
|
||||
CPSections[SecIdx].Alignment = Alignment;
|
||||
CPSections[SecIdx].CPEs.push_back(i);
|
||||
}
|
||||
|
||||
@ -2903,9 +2903,10 @@ MCSymbol *AsmPrinter::GetCPISymbol(unsigned CPID) const {
|
||||
const DataLayout &DL = MF->getDataLayout();
|
||||
SectionKind Kind = CPE.getSectionKind(&DL);
|
||||
const Constant *C = CPE.Val.ConstVal;
|
||||
unsigned Align = CPE.Alignment.value();
|
||||
Align Alignment = CPE.Alignment;
|
||||
if (const MCSectionCOFF *S = dyn_cast<MCSectionCOFF>(
|
||||
getObjFileLowering().getSectionForConstant(DL, Kind, C, Align))) {
|
||||
getObjFileLowering().getSectionForConstant(DL, Kind, C,
|
||||
Alignment))) {
|
||||
if (MCSymbol *Sym = S->getCOMDATSymbol()) {
|
||||
if (Sym->isUndefined())
|
||||
OutStreamer->emitSymbolAttribute(Sym, MCSA_Global);
|
||||
|
@ -842,7 +842,7 @@ bool TargetLoweringObjectFileELF::shouldPutJumpTableInFunctionSection(
|
||||
/// information, return a section that it should be placed in.
|
||||
MCSection *TargetLoweringObjectFileELF::getSectionForConstant(
|
||||
const DataLayout &DL, SectionKind Kind, const Constant *C,
|
||||
unsigned &Align) const {
|
||||
Align &Alignment) const {
|
||||
if (Kind.isMergeableConst4() && MergeableConst4Section)
|
||||
return MergeableConst4Section;
|
||||
if (Kind.isMergeableConst8() && MergeableConst8Section)
|
||||
@ -1194,7 +1194,7 @@ MCSection *TargetLoweringObjectFileMachO::SelectSectionForGlobal(
|
||||
|
||||
MCSection *TargetLoweringObjectFileMachO::getSectionForConstant(
|
||||
const DataLayout &DL, SectionKind Kind, const Constant *C,
|
||||
unsigned &Align) const {
|
||||
Align &Alignment) const {
|
||||
// If this constant requires a relocation, we have to put it in the data
|
||||
// segment, not in the text segment.
|
||||
if (Kind.isData() || Kind.isReadOnlyWithRel())
|
||||
@ -1777,7 +1777,7 @@ static std::string scalarConstantToHexString(const Constant *C) {
|
||||
|
||||
MCSection *TargetLoweringObjectFileCOFF::getSectionForConstant(
|
||||
const DataLayout &DL, SectionKind Kind, const Constant *C,
|
||||
unsigned &Align) const {
|
||||
Align &Alignment) const {
|
||||
if (Kind.isMergeableConst() && C &&
|
||||
getContext().getAsmInfo()->hasCOFFComdatConstants()) {
|
||||
// This creates comdat sections with the given symbol name, but unless
|
||||
@ -1789,25 +1789,25 @@ MCSection *TargetLoweringObjectFileCOFF::getSectionForConstant(
|
||||
COFF::IMAGE_SCN_LNK_COMDAT;
|
||||
std::string COMDATSymName;
|
||||
if (Kind.isMergeableConst4()) {
|
||||
if (Align <= 4) {
|
||||
if (Alignment <= 4) {
|
||||
COMDATSymName = "__real@" + scalarConstantToHexString(C);
|
||||
Align = 4;
|
||||
Alignment = Align(4);
|
||||
}
|
||||
} else if (Kind.isMergeableConst8()) {
|
||||
if (Align <= 8) {
|
||||
if (Alignment <= 8) {
|
||||
COMDATSymName = "__real@" + scalarConstantToHexString(C);
|
||||
Align = 8;
|
||||
Alignment = Align(8);
|
||||
}
|
||||
} else if (Kind.isMergeableConst16()) {
|
||||
// FIXME: These may not be appropriate for non-x86 architectures.
|
||||
if (Align <= 16) {
|
||||
if (Alignment <= 16) {
|
||||
COMDATSymName = "__xmm@" + scalarConstantToHexString(C);
|
||||
Align = 16;
|
||||
Alignment = Align(16);
|
||||
}
|
||||
} else if (Kind.isMergeableConst32()) {
|
||||
if (Align <= 32) {
|
||||
if (Alignment <= 32) {
|
||||
COMDATSymName = "__ymm@" + scalarConstantToHexString(C);
|
||||
Align = 32;
|
||||
Alignment = Align(32);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1817,10 +1817,10 @@ MCSection *TargetLoweringObjectFileCOFF::getSectionForConstant(
|
||||
COFF::IMAGE_COMDAT_SELECT_ANY);
|
||||
}
|
||||
|
||||
return TargetLoweringObjectFile::getSectionForConstant(DL, Kind, C, Align);
|
||||
return TargetLoweringObjectFile::getSectionForConstant(DL, Kind, C,
|
||||
Alignment);
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Wasm
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -2096,7 +2096,7 @@ bool TargetLoweringObjectFileXCOFF::shouldPutJumpTableInFunctionSection(
|
||||
/// information, return a section that it should be placed in.
|
||||
MCSection *TargetLoweringObjectFileXCOFF::getSectionForConstant(
|
||||
const DataLayout &DL, SectionKind Kind, const Constant *C,
|
||||
unsigned &Align) const {
|
||||
Align &Alignment) const {
|
||||
//TODO: Enable emiting constant pool to unique sections when we support it.
|
||||
return ReadOnlySection;
|
||||
}
|
||||
|
@ -116,13 +116,13 @@ bool LanaiTargetObjectFile::isConstantInSmallSection(const DataLayout &DL,
|
||||
return isInSmallSection(DL.getTypeAllocSize(CN->getType()));
|
||||
}
|
||||
|
||||
MCSection *LanaiTargetObjectFile::getSectionForConstant(const DataLayout &DL,
|
||||
SectionKind Kind,
|
||||
const Constant *C,
|
||||
unsigned &Align) const {
|
||||
MCSection *LanaiTargetObjectFile::getSectionForConstant(
|
||||
const DataLayout &DL, SectionKind Kind, const Constant *C,
|
||||
Align &Alignment) const {
|
||||
if (isConstantInSmallSection(DL, C))
|
||||
return SmallDataSection;
|
||||
|
||||
// Otherwise, we work the same as ELF.
|
||||
return TargetLoweringObjectFileELF::getSectionForConstant(DL, Kind, C, Align);
|
||||
return TargetLoweringObjectFileELF::getSectionForConstant(DL, Kind, C,
|
||||
Alignment);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
|
||||
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||
const Constant *C,
|
||||
unsigned &Align) const override;
|
||||
Align &Alignment) const override;
|
||||
};
|
||||
} // end namespace llvm
|
||||
|
||||
|
@ -176,12 +176,13 @@ bool MipsTargetObjectFile::IsConstantInSmallSection(
|
||||
MCSection *MipsTargetObjectFile::getSectionForConstant(const DataLayout &DL,
|
||||
SectionKind Kind,
|
||||
const Constant *C,
|
||||
unsigned &Align) const {
|
||||
Align &Alignment) const {
|
||||
if (IsConstantInSmallSection(DL, C, *TM))
|
||||
return SmallDataSection;
|
||||
|
||||
// Otherwise, we work the same as ELF.
|
||||
return TargetLoweringObjectFileELF::getSectionForConstant(DL, Kind, C, Align);
|
||||
return TargetLoweringObjectFileELF::getSectionForConstant(DL, Kind, C,
|
||||
Alignment);
|
||||
}
|
||||
|
||||
const MCExpr *
|
||||
|
@ -40,7 +40,7 @@ class MipsTargetMachine;
|
||||
|
||||
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||
const Constant *C,
|
||||
unsigned &Align) const override;
|
||||
Align &Alignment) const override;
|
||||
/// Describe a TLS variable address within debug info.
|
||||
const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const override;
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
|
||||
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||
const Constant *C,
|
||||
unsigned &Align) const override {
|
||||
Align &Alignment) const override {
|
||||
return ReadOnlySection;
|
||||
}
|
||||
|
||||
|
@ -104,10 +104,11 @@ bool RISCVELFTargetObjectFile::isConstantInSmallSection(
|
||||
|
||||
MCSection *RISCVELFTargetObjectFile::getSectionForConstant(
|
||||
const DataLayout &DL, SectionKind Kind, const Constant *C,
|
||||
unsigned &Align) const {
|
||||
Align &Alignment) const {
|
||||
if (isConstantInSmallSection(DL, C))
|
||||
return SmallDataSection;
|
||||
|
||||
// Otherwise, we work the same as ELF.
|
||||
return TargetLoweringObjectFileELF::getSectionForConstant(DL, Kind, C, Align);
|
||||
return TargetLoweringObjectFileELF::getSectionForConstant(DL, Kind, C,
|
||||
Alignment);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||
const Constant *C,
|
||||
unsigned &Align) const override;
|
||||
Align &Alignment) const override;
|
||||
|
||||
void getModuleMetadata(Module &M) override;
|
||||
|
||||
|
@ -284,10 +284,10 @@ TargetLoweringObjectFile::SectionForGlobal(const GlobalObject *GO,
|
||||
|
||||
MCSection *TargetLoweringObjectFile::getSectionForJumpTable(
|
||||
const Function &F, const TargetMachine &TM) const {
|
||||
unsigned Align = 0;
|
||||
Align Alignment(1);
|
||||
return getSectionForConstant(F.getParent()->getDataLayout(),
|
||||
SectionKind::getReadOnly(), /*C=*/nullptr,
|
||||
Align);
|
||||
Alignment);
|
||||
}
|
||||
|
||||
bool TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection(
|
||||
@ -309,7 +309,7 @@ bool TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection(
|
||||
/// information, return a section that it should be placed in.
|
||||
MCSection *TargetLoweringObjectFile::getSectionForConstant(
|
||||
const DataLayout &DL, SectionKind Kind, const Constant *C,
|
||||
unsigned &Align) const {
|
||||
Align &Alignment) const {
|
||||
if (Kind.isReadOnly() && ReadOnlySection != nullptr)
|
||||
return ReadOnlySection;
|
||||
|
||||
|
@ -140,10 +140,9 @@ MCSection *XCoreTargetObjectFile::SelectSectionForGlobal(
|
||||
report_fatal_error("Target does not support TLS or Common sections");
|
||||
}
|
||||
|
||||
MCSection *XCoreTargetObjectFile::getSectionForConstant(const DataLayout &DL,
|
||||
SectionKind Kind,
|
||||
const Constant *C,
|
||||
unsigned &Align) const {
|
||||
MCSection *XCoreTargetObjectFile::getSectionForConstant(
|
||||
const DataLayout &DL, SectionKind Kind, const Constant *C,
|
||||
Align &Alignment) const {
|
||||
if (Kind.isMergeableConst4()) return MergeableConst4Section;
|
||||
if (Kind.isMergeableConst8()) return MergeableConst8Section;
|
||||
if (Kind.isMergeableConst16()) return MergeableConst16Section;
|
||||
|
@ -32,7 +32,7 @@ static const unsigned CodeModelLargeSize = 256;
|
||||
|
||||
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||
const Constant *C,
|
||||
unsigned &Align) const override;
|
||||
Align &Alignment) const override;
|
||||
};
|
||||
} // end namespace llvm
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user