mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-02 22:32:08 +00:00
Remove DataLayout from TargetLoweringObjectFile, redirect to Module
Summary: This change is part of a series of commits dedicated to have a single DataLayout during compilation by using always the one owned by the module. Reviewers: echristo Subscribers: yaron.keren, rafael, llvm-commits, jholewinski Differential Revision: http://reviews.llvm.org/D11079 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242385 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
24e2a7c43f
commit
a5574d611a
@ -41,12 +41,12 @@ public:
|
|||||||
|
|
||||||
~TargetLoweringObjectFileELF() override {}
|
~TargetLoweringObjectFileELF() override {}
|
||||||
|
|
||||||
void emitPersonalityValue(MCStreamer &Streamer, const TargetMachine &TM,
|
void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM,
|
||||||
const MCSymbol *Sym) const override;
|
const MCSymbol *Sym) const override;
|
||||||
|
|
||||||
/// Given a constant with the SectionKind, return a section that it should be
|
/// Given a constant with the SectionKind, return a section that it should be
|
||||||
/// placed in.
|
/// placed in.
|
||||||
MCSection *getSectionForConstant(SectionKind Kind,
|
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||||
const Constant *C) const override;
|
const Constant *C) const override;
|
||||||
|
|
||||||
MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
|
MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
|
||||||
@ -103,7 +103,7 @@ public:
|
|||||||
Mangler &Mang,
|
Mangler &Mang,
|
||||||
const TargetMachine &TM) const override;
|
const TargetMachine &TM) const override;
|
||||||
|
|
||||||
MCSection *getSectionForConstant(SectionKind Kind,
|
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||||
const Constant *C) const override;
|
const Constant *C) const override;
|
||||||
|
|
||||||
/// The mach-o version of this method defaults to returning a stub reference.
|
/// The mach-o version of this method defaults to returning a stub reference.
|
||||||
|
@ -42,16 +42,15 @@ class TargetLoweringObjectFile : public MCObjectFileInfo {
|
|||||||
void operator=(const TargetLoweringObjectFile&) = delete;
|
void operator=(const TargetLoweringObjectFile&) = delete;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const DataLayout *DL;
|
|
||||||
bool SupportIndirectSymViaGOTPCRel;
|
bool SupportIndirectSymViaGOTPCRel;
|
||||||
bool SupportGOTPCRelWithOffset;
|
bool SupportGOTPCRelWithOffset;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MCContext &getContext() const { return *Ctx; }
|
MCContext &getContext() const { return *Ctx; }
|
||||||
|
|
||||||
TargetLoweringObjectFile() : MCObjectFileInfo(), Ctx(nullptr), DL(nullptr),
|
TargetLoweringObjectFile()
|
||||||
SupportIndirectSymViaGOTPCRel(false),
|
: MCObjectFileInfo(), Ctx(nullptr), SupportIndirectSymViaGOTPCRel(false),
|
||||||
SupportGOTPCRelWithOffset(true) {}
|
SupportGOTPCRelWithOffset(true) {}
|
||||||
|
|
||||||
virtual ~TargetLoweringObjectFile();
|
virtual ~TargetLoweringObjectFile();
|
||||||
|
|
||||||
@ -60,8 +59,7 @@ public:
|
|||||||
/// implementations a chance to set up their default sections.
|
/// implementations a chance to set up their default sections.
|
||||||
virtual void Initialize(MCContext &ctx, const TargetMachine &TM);
|
virtual void Initialize(MCContext &ctx, const TargetMachine &TM);
|
||||||
|
|
||||||
virtual void emitPersonalityValue(MCStreamer &Streamer,
|
virtual void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM,
|
||||||
const TargetMachine &TM,
|
|
||||||
const MCSymbol *Sym) const;
|
const MCSymbol *Sym) const;
|
||||||
|
|
||||||
/// Emit the module flags that the platform cares about.
|
/// Emit the module flags that the platform cares about.
|
||||||
@ -71,7 +69,8 @@ public:
|
|||||||
|
|
||||||
/// Given a constant with the SectionKind, return a section that it should be
|
/// Given a constant with the SectionKind, return a section that it should be
|
||||||
/// placed in.
|
/// placed in.
|
||||||
virtual MCSection *getSectionForConstant(SectionKind Kind,
|
virtual MCSection *getSectionForConstant(const DataLayout &DL,
|
||||||
|
SectionKind Kind,
|
||||||
const Constant *C) const;
|
const Constant *C) const;
|
||||||
|
|
||||||
/// Classify the specified global variable into a set of target independent
|
/// Classify the specified global variable into a set of target independent
|
||||||
|
@ -137,7 +137,7 @@ const TargetLoweringObjectFile &AsmPrinter::getObjFileLowering() const {
|
|||||||
|
|
||||||
/// getDataLayout - Return information about data layout.
|
/// getDataLayout - Return information about data layout.
|
||||||
const DataLayout &AsmPrinter::getDataLayout() const {
|
const DataLayout &AsmPrinter::getDataLayout() const {
|
||||||
return *TM.getDataLayout();
|
return MMI->getModule()->getDataLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned AsmPrinter::getPointerSize() const { return TM.getDataLayout()->getPointerSize(); }
|
unsigned AsmPrinter::getPointerSize() const { return TM.getDataLayout()->getPointerSize(); }
|
||||||
@ -377,13 +377,13 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
|
|||||||
|
|
||||||
SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM);
|
SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM);
|
||||||
|
|
||||||
const DataLayout *DL = TM.getDataLayout();
|
const DataLayout &DL = GV->getParent()->getDataLayout();
|
||||||
uint64_t Size = DL->getTypeAllocSize(GV->getType()->getElementType());
|
uint64_t Size = DL.getTypeAllocSize(GV->getType()->getElementType());
|
||||||
|
|
||||||
// If the alignment is specified, we *must* obey it. Overaligning a global
|
// If the alignment is specified, we *must* obey it. Overaligning a global
|
||||||
// with a specified alignment is a prompt way to break globals emitted to
|
// with a specified alignment is a prompt way to break globals emitted to
|
||||||
// sections and expected to be contiguous (e.g. ObjC metadata).
|
// sections and expected to be contiguous (e.g. ObjC metadata).
|
||||||
unsigned AlignLog = getGVAlignmentLog2(GV, *DL);
|
unsigned AlignLog = getGVAlignmentLog2(GV, DL);
|
||||||
|
|
||||||
for (const HandlerInfo &HI : Handlers) {
|
for (const HandlerInfo &HI : Handlers) {
|
||||||
NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, TimePassesIsEnabled);
|
NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, TimePassesIsEnabled);
|
||||||
@ -492,7 +492,7 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
|
|||||||
// - __tlv_bootstrap - used to make sure support exists
|
// - __tlv_bootstrap - used to make sure support exists
|
||||||
// - spare pointer, used when mapped by the runtime
|
// - spare pointer, used when mapped by the runtime
|
||||||
// - pointer to mangled symbol above with initializer
|
// - pointer to mangled symbol above with initializer
|
||||||
unsigned PtrSize = DL->getPointerTypeSize(GV->getType());
|
unsigned PtrSize = DL.getPointerTypeSize(GV->getType());
|
||||||
OutStreamer->EmitSymbolValue(GetExternalSymbolSymbol("_tlv_bootstrap"),
|
OutStreamer->EmitSymbolValue(GetExternalSymbolSymbol("_tlv_bootstrap"),
|
||||||
PtrSize);
|
PtrSize);
|
||||||
OutStreamer->EmitIntValue(0, PtrSize);
|
OutStreamer->EmitIntValue(0, PtrSize);
|
||||||
@ -1122,9 +1122,8 @@ bool AsmPrinter::doFinalization(Module &M) {
|
|||||||
|
|
||||||
// Emit __morestack address if needed for indirect calls.
|
// Emit __morestack address if needed for indirect calls.
|
||||||
if (MMI->usesMorestackAddr()) {
|
if (MMI->usesMorestackAddr()) {
|
||||||
MCSection *ReadOnlySection =
|
MCSection *ReadOnlySection = getObjFileLowering().getSectionForConstant(
|
||||||
getObjFileLowering().getSectionForConstant(SectionKind::getReadOnly(),
|
getDataLayout(), SectionKind::getReadOnly(), /*C=*/nullptr);
|
||||||
/*C=*/nullptr);
|
|
||||||
OutStreamer->SwitchSection(ReadOnlySection);
|
OutStreamer->SwitchSection(ReadOnlySection);
|
||||||
|
|
||||||
MCSymbol *AddrSymbol =
|
MCSymbol *AddrSymbol =
|
||||||
@ -1215,7 +1214,8 @@ void AsmPrinter::EmitConstantPool() {
|
|||||||
if (!CPE.isMachineConstantPoolEntry())
|
if (!CPE.isMachineConstantPoolEntry())
|
||||||
C = CPE.Val.ConstVal;
|
C = CPE.Val.ConstVal;
|
||||||
|
|
||||||
MCSection *S = getObjFileLowering().getSectionForConstant(Kind, C);
|
MCSection *S =
|
||||||
|
getObjFileLowering().getSectionForConstant(getDataLayout(), Kind, C);
|
||||||
|
|
||||||
// The number of sections are small, just do a linear search from the
|
// The number of sections are small, just do a linear search from the
|
||||||
// last section to the first.
|
// last section to the first.
|
||||||
|
@ -83,7 +83,7 @@ void DwarfCFIException::endModule() {
|
|||||||
if (!Personalities[i])
|
if (!Personalities[i])
|
||||||
continue;
|
continue;
|
||||||
MCSymbol *Sym = Asm->getSymbol(Personalities[i]);
|
MCSymbol *Sym = Asm->getSymbol(Personalities[i]);
|
||||||
TLOF.emitPersonalityValue(*Asm->OutStreamer, Asm->TM, Sym);
|
TLOF.emitPersonalityValue(*Asm->OutStreamer, Asm->getDataLayout(), Sym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,9 +58,8 @@ MCSymbol *TargetLoweringObjectFileELF::getCFIPersonalitySymbol(
|
|||||||
report_fatal_error("We do not support this DWARF encoding yet!");
|
report_fatal_error("We do not support this DWARF encoding yet!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetLoweringObjectFileELF::emitPersonalityValue(MCStreamer &Streamer,
|
void TargetLoweringObjectFileELF::emitPersonalityValue(
|
||||||
const TargetMachine &TM,
|
MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym) const {
|
||||||
const MCSymbol *Sym) const {
|
|
||||||
SmallString<64> NameData("DW.ref.");
|
SmallString<64> NameData("DW.ref.");
|
||||||
NameData += Sym->getName();
|
NameData += Sym->getName();
|
||||||
MCSymbolELF *Label =
|
MCSymbolELF *Label =
|
||||||
@ -72,9 +71,9 @@ void TargetLoweringObjectFileELF::emitPersonalityValue(MCStreamer &Streamer,
|
|||||||
unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_GROUP;
|
unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_GROUP;
|
||||||
MCSection *Sec = getContext().getELFSection(NameData, ELF::SHT_PROGBITS,
|
MCSection *Sec = getContext().getELFSection(NameData, ELF::SHT_PROGBITS,
|
||||||
Flags, 0, Label->getName());
|
Flags, 0, Label->getName());
|
||||||
unsigned Size = TM.getDataLayout()->getPointerSize();
|
unsigned Size = DL.getPointerSize();
|
||||||
Streamer.SwitchSection(Sec);
|
Streamer.SwitchSection(Sec);
|
||||||
Streamer.EmitValueToAlignment(TM.getDataLayout()->getPointerABIAlignment());
|
Streamer.EmitValueToAlignment(DL.getPointerABIAlignment());
|
||||||
Streamer.EmitSymbolAttribute(Label, MCSA_ELF_TypeObject);
|
Streamer.EmitSymbolAttribute(Label, MCSA_ELF_TypeObject);
|
||||||
const MCExpr *E = MCConstantExpr::create(Size, getContext());
|
const MCExpr *E = MCConstantExpr::create(Size, getContext());
|
||||||
Streamer.emitELFSize(Label, E);
|
Streamer.emitELFSize(Label, E);
|
||||||
@ -282,8 +281,8 @@ selectELFSectionForGlobal(MCContext &Ctx, const GlobalValue *GV,
|
|||||||
// We also need alignment here.
|
// We also need alignment here.
|
||||||
// FIXME: this is getting the alignment of the character, not the
|
// FIXME: this is getting the alignment of the character, not the
|
||||||
// alignment of the global!
|
// alignment of the global!
|
||||||
unsigned Align =
|
unsigned Align = GV->getParent()->getDataLayout().getPreferredAlignment(
|
||||||
TM.getDataLayout()->getPreferredAlignment(cast<GlobalVariable>(GV));
|
cast<GlobalVariable>(GV));
|
||||||
|
|
||||||
std::string SizeSpec = ".rodata.str" + utostr(EntrySize) + ".";
|
std::string SizeSpec = ".rodata.str" + utostr(EntrySize) + ".";
|
||||||
Name = SizeSpec + utostr(Align);
|
Name = SizeSpec + utostr(Align);
|
||||||
@ -350,9 +349,8 @@ bool TargetLoweringObjectFileELF::shouldPutJumpTableInFunctionSection(
|
|||||||
|
|
||||||
/// Given a mergeable constant with the specified size and relocation
|
/// Given a mergeable constant with the specified size and relocation
|
||||||
/// information, return a section that it should be placed in.
|
/// information, return a section that it should be placed in.
|
||||||
MCSection *
|
MCSection *TargetLoweringObjectFileELF::getSectionForConstant(
|
||||||
TargetLoweringObjectFileELF::getSectionForConstant(SectionKind Kind,
|
const DataLayout &DL, SectionKind Kind, const Constant *C) const {
|
||||||
const Constant *C) const {
|
|
||||||
if (Kind.isMergeableConst4() && MergeableConst4Section)
|
if (Kind.isMergeableConst4() && MergeableConst4Section)
|
||||||
return MergeableConst4Section;
|
return MergeableConst4Section;
|
||||||
if (Kind.isMergeableConst8() && MergeableConst8Section)
|
if (Kind.isMergeableConst8() && MergeableConst8Section)
|
||||||
@ -589,14 +587,16 @@ MCSection *TargetLoweringObjectFileMachO::SelectSectionForGlobal(
|
|||||||
|
|
||||||
// FIXME: Alignment check should be handled by section classifier.
|
// FIXME: Alignment check should be handled by section classifier.
|
||||||
if (Kind.isMergeable1ByteCString() &&
|
if (Kind.isMergeable1ByteCString() &&
|
||||||
TM.getDataLayout()->getPreferredAlignment(cast<GlobalVariable>(GV)) < 32)
|
GV->getParent()->getDataLayout().getPreferredAlignment(
|
||||||
|
cast<GlobalVariable>(GV)) < 32)
|
||||||
return CStringSection;
|
return CStringSection;
|
||||||
|
|
||||||
// Do not put 16-bit arrays in the UString section if they have an
|
// Do not put 16-bit arrays in the UString section if they have an
|
||||||
// externally visible label, this runs into issues with certain linker
|
// externally visible label, this runs into issues with certain linker
|
||||||
// versions.
|
// versions.
|
||||||
if (Kind.isMergeable2ByteCString() && !GV->hasExternalLinkage() &&
|
if (Kind.isMergeable2ByteCString() && !GV->hasExternalLinkage() &&
|
||||||
TM.getDataLayout()->getPreferredAlignment(cast<GlobalVariable>(GV)) < 32)
|
GV->getParent()->getDataLayout().getPreferredAlignment(
|
||||||
|
cast<GlobalVariable>(GV)) < 32)
|
||||||
return UStringSection;
|
return UStringSection;
|
||||||
|
|
||||||
// With MachO only variables whose corresponding symbol starts with 'l' or
|
// With MachO only variables whose corresponding symbol starts with 'l' or
|
||||||
@ -634,9 +634,8 @@ MCSection *TargetLoweringObjectFileMachO::SelectSectionForGlobal(
|
|||||||
return DataSection;
|
return DataSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSection *
|
MCSection *TargetLoweringObjectFileMachO::getSectionForConstant(
|
||||||
TargetLoweringObjectFileMachO::getSectionForConstant(SectionKind Kind,
|
const DataLayout &DL, SectionKind Kind, const Constant *C) const {
|
||||||
const Constant *C) const {
|
|
||||||
// If this constant requires a relocation, we have to put it in the data
|
// If this constant requires a relocation, we have to put it in the data
|
||||||
// segment, not in the text segment.
|
// segment, not in the text segment.
|
||||||
if (Kind.isDataRel() || Kind.isReadOnlyWithRel())
|
if (Kind.isDataRel() || Kind.isReadOnlyWithRel())
|
||||||
@ -740,7 +739,7 @@ const MCExpr *TargetLoweringObjectFileMachO::getIndirectSymViaGOTPCRel(
|
|||||||
// non_lazy_ptr stubs.
|
// non_lazy_ptr stubs.
|
||||||
SmallString<128> Name;
|
SmallString<128> Name;
|
||||||
StringRef Suffix = "$non_lazy_ptr";
|
StringRef Suffix = "$non_lazy_ptr";
|
||||||
Name += DL->getPrivateGlobalPrefix();
|
Name += MMI->getModule()->getDataLayout().getPrivateGlobalPrefix();
|
||||||
Name += Sym->getName();
|
Name += Sym->getName();
|
||||||
Name += Suffix;
|
Name += Suffix;
|
||||||
MCSymbol *Stub = Ctx.getOrCreateSymbol(Name);
|
MCSymbol *Stub = Ctx.getOrCreateSymbol(Name);
|
||||||
@ -1043,7 +1042,7 @@ void TargetLoweringObjectFileCOFF::emitLinkerFlagsForGlobal(
|
|||||||
raw_string_ostream FlagOS(Flag);
|
raw_string_ostream FlagOS(Flag);
|
||||||
Mang.getNameWithPrefix(FlagOS, GV, false);
|
Mang.getNameWithPrefix(FlagOS, GV, false);
|
||||||
FlagOS.flush();
|
FlagOS.flush();
|
||||||
if (Flag[0] == DL->getGlobalPrefix())
|
if (Flag[0] == GV->getParent()->getDataLayout().getGlobalPrefix())
|
||||||
OS << Flag.substr(1);
|
OS << Flag.substr(1);
|
||||||
else
|
else
|
||||||
OS << Flag;
|
OS << Flag;
|
||||||
|
@ -107,7 +107,8 @@ IsGlobalInSmallSectionImpl(const GlobalValue *GV,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
Type *Ty = GV->getType()->getElementType();
|
Type *Ty = GV->getType()->getElementType();
|
||||||
return IsInSmallSection(TM.getDataLayout()->getTypeAllocSize(Ty));
|
return IsInSmallSection(
|
||||||
|
GV->getParent()->getDataLayout().getTypeAllocSize(Ty));
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSection *
|
MCSection *
|
||||||
@ -137,12 +138,12 @@ IsConstantInSmallSection(const Constant *CN, const TargetMachine &TM) const {
|
|||||||
CN->getType())));
|
CN->getType())));
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSection *
|
/// Return true if this constant should be placed into small data section.
|
||||||
MipsTargetObjectFile::getSectionForConstant(SectionKind Kind,
|
MCSection *MipsTargetObjectFile::getSectionForConstant(
|
||||||
const Constant *C) const {
|
const DataLayout &DL, SectionKind Kind, const Constant *C) const {
|
||||||
if (IsConstantInSmallSection(C, *TM))
|
if (IsConstantInSmallSection(C, *TM))
|
||||||
return SmallDataSection;
|
return SmallDataSection;
|
||||||
|
|
||||||
// Otherwise, we work the same as ELF.
|
// Otherwise, we work the same as ELF.
|
||||||
return TargetLoweringObjectFileELF::getSectionForConstant(Kind, C);
|
return TargetLoweringObjectFileELF::getSectionForConstant(DL, Kind, C);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ class MipsTargetMachine;
|
|||||||
bool IsConstantInSmallSection(const Constant *CN,
|
bool IsConstantInSmallSection(const Constant *CN,
|
||||||
const TargetMachine &TM) const;
|
const TargetMachine &TM) const;
|
||||||
|
|
||||||
MCSection *getSectionForConstant(SectionKind Kind,
|
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||||
const Constant *C) const override;
|
const Constant *C) const override;
|
||||||
};
|
};
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
|
new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSection *getSectionForConstant(SectionKind Kind,
|
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||||
const Constant *C) const override {
|
const Constant *C) const override {
|
||||||
return ReadOnlySection;
|
return ReadOnlySection;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,6 @@ using namespace llvm;
|
|||||||
void TargetLoweringObjectFile::Initialize(MCContext &ctx,
|
void TargetLoweringObjectFile::Initialize(MCContext &ctx,
|
||||||
const TargetMachine &TM) {
|
const TargetMachine &TM) {
|
||||||
Ctx = &ctx;
|
Ctx = &ctx;
|
||||||
DL = TM.getDataLayout();
|
|
||||||
InitMCObjectFileInfo(TM.getTargetTriple(), TM.getRelocationModel(),
|
InitMCObjectFileInfo(TM.getTargetTriple(), TM.getRelocationModel(),
|
||||||
TM.getCodeModel(), *Ctx);
|
TM.getCodeModel(), *Ctx);
|
||||||
}
|
}
|
||||||
@ -107,7 +106,7 @@ MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase(
|
|||||||
assert(!Suffix.empty());
|
assert(!Suffix.empty());
|
||||||
|
|
||||||
SmallString<60> NameStr;
|
SmallString<60> NameStr;
|
||||||
NameStr += DL->getPrivateGlobalPrefix();
|
NameStr += GV->getParent()->getDataLayout().getPrivateGlobalPrefix();
|
||||||
TM.getNameWithPrefix(NameStr, GV, Mang);
|
TM.getNameWithPrefix(NameStr, GV, Mang);
|
||||||
NameStr.append(Suffix.begin(), Suffix.end());
|
NameStr.append(Suffix.begin(), Suffix.end());
|
||||||
return Ctx->getOrCreateSymbol(NameStr);
|
return Ctx->getOrCreateSymbol(NameStr);
|
||||||
@ -120,7 +119,7 @@ MCSymbol *TargetLoweringObjectFile::getCFIPersonalitySymbol(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
|
void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
|
||||||
const TargetMachine &TM,
|
const DataLayout &,
|
||||||
const MCSymbol *Sym) const {
|
const MCSymbol *Sym) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +199,7 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV,
|
|||||||
// Otherwise, just drop it into a mergable constant section. If we have
|
// Otherwise, just drop it into a mergable constant section. If we have
|
||||||
// a section for this size, use it, otherwise use the arbitrary sized
|
// a section for this size, use it, otherwise use the arbitrary sized
|
||||||
// mergable section.
|
// mergable section.
|
||||||
switch (TM.getDataLayout()->getTypeAllocSize(C->getType())) {
|
switch (GV->getParent()->getDataLayout().getTypeAllocSize(C->getType())) {
|
||||||
case 4: return SectionKind::getMergeableConst4();
|
case 4: return SectionKind::getMergeableConst4();
|
||||||
case 8: return SectionKind::getMergeableConst8();
|
case 8: return SectionKind::getMergeableConst8();
|
||||||
case 16: return SectionKind::getMergeableConst16();
|
case 16: return SectionKind::getMergeableConst16();
|
||||||
@ -273,7 +272,8 @@ TargetLoweringObjectFile::SectionForGlobal(const GlobalValue *GV,
|
|||||||
|
|
||||||
MCSection *TargetLoweringObjectFile::getSectionForJumpTable(
|
MCSection *TargetLoweringObjectFile::getSectionForJumpTable(
|
||||||
const Function &F, Mangler &Mang, const TargetMachine &TM) const {
|
const Function &F, Mangler &Mang, const TargetMachine &TM) const {
|
||||||
return getSectionForConstant(SectionKind::getReadOnly(), /*C=*/nullptr);
|
return getSectionForConstant(F.getParent()->getDataLayout(),
|
||||||
|
SectionKind::getReadOnly(), /*C=*/nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection(
|
bool TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection(
|
||||||
@ -296,9 +296,8 @@ bool TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection(
|
|||||||
|
|
||||||
/// Given a mergable constant with the specified size and relocation
|
/// Given a mergable constant with the specified size and relocation
|
||||||
/// information, return a section that it should be placed in.
|
/// information, return a section that it should be placed in.
|
||||||
MCSection *
|
MCSection *TargetLoweringObjectFile::getSectionForConstant(
|
||||||
TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind,
|
const DataLayout &DL, SectionKind Kind, const Constant *C) const {
|
||||||
const Constant *C) const {
|
|
||||||
if (Kind.isReadOnly() && ReadOnlySection != nullptr)
|
if (Kind.isReadOnly() && ReadOnlySection != nullptr)
|
||||||
return ReadOnlySection;
|
return ReadOnlySection;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
DwarfRangesSection = nullptr;
|
DwarfRangesSection = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSection *getSectionForConstant(SectionKind Kind,
|
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||||
const Constant *C) const override {
|
const Constant *C) const override {
|
||||||
return ReadOnlySection;
|
return ReadOnlySection;
|
||||||
}
|
}
|
||||||
|
@ -565,10 +565,11 @@ MCSymbol *X86AsmPrinter::GetCPISymbol(unsigned CPID) const {
|
|||||||
const MachineConstantPoolEntry &CPE =
|
const MachineConstantPoolEntry &CPE =
|
||||||
MF->getConstantPool()->getConstants()[CPID];
|
MF->getConstantPool()->getConstants()[CPID];
|
||||||
if (!CPE.isMachineConstantPoolEntry()) {
|
if (!CPE.isMachineConstantPoolEntry()) {
|
||||||
SectionKind Kind = CPE.getSectionKind(TM.getDataLayout());
|
const DataLayout &DL = MF->getDataLayout();
|
||||||
|
SectionKind Kind = CPE.getSectionKind(&DL);
|
||||||
const Constant *C = CPE.Val.ConstVal;
|
const Constant *C = CPE.Val.ConstVal;
|
||||||
if (const MCSectionCOFF *S = dyn_cast<MCSectionCOFF>(
|
if (const MCSectionCOFF *S = dyn_cast<MCSectionCOFF>(
|
||||||
getObjFileLowering().getSectionForConstant(Kind, C))) {
|
getObjFileLowering().getSectionForConstant(DL, Kind, C))) {
|
||||||
if (MCSymbol *Sym = S->getCOMDATSymbol()) {
|
if (MCSymbol *Sym = S->getCOMDATSymbol()) {
|
||||||
if (Sym->isUndefined())
|
if (Sym->isUndefined())
|
||||||
OutStreamer->EmitSymbolAttribute(Sym, MCSA_Global);
|
OutStreamer->EmitSymbolAttribute(Sym, MCSA_Global);
|
||||||
|
@ -152,9 +152,8 @@ static std::string scalarConstantToHexString(const Constant *C) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSection *
|
MCSection *X86WindowsTargetObjectFile::getSectionForConstant(
|
||||||
X86WindowsTargetObjectFile::getSectionForConstant(SectionKind Kind,
|
const DataLayout &DL, SectionKind Kind, const Constant *C) const {
|
||||||
const Constant *C) const {
|
|
||||||
if (Kind.isMergeableConst() && C) {
|
if (Kind.isMergeableConst() && C) {
|
||||||
const unsigned Characteristics = COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
const unsigned Characteristics = COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
|
||||||
COFF::IMAGE_SCN_MEM_READ |
|
COFF::IMAGE_SCN_MEM_READ |
|
||||||
@ -171,5 +170,5 @@ X86WindowsTargetObjectFile::getSectionForConstant(SectionKind Kind,
|
|||||||
COFF::IMAGE_COMDAT_SELECT_ANY);
|
COFF::IMAGE_COMDAT_SELECT_ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TargetLoweringObjectFile::getSectionForConstant(Kind, C);
|
return TargetLoweringObjectFile::getSectionForConstant(DL, Kind, C);
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ namespace llvm {
|
|||||||
|
|
||||||
/// \brief Given a mergeable constant with the specified size and relocation
|
/// \brief Given a mergeable constant with the specified size and relocation
|
||||||
/// information, return a section that it should be placed in.
|
/// information, return a section that it should be placed in.
|
||||||
MCSection *getSectionForConstant(SectionKind Kind,
|
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||||
const Constant *C) const override;
|
const Constant *C) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -142,9 +142,8 @@ XCoreTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
|
|||||||
report_fatal_error("Target does not support TLS or Common sections");
|
report_fatal_error("Target does not support TLS or Common sections");
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSection *
|
MCSection *XCoreTargetObjectFile::getSectionForConstant(
|
||||||
XCoreTargetObjectFile::getSectionForConstant(SectionKind Kind,
|
const DataLayout &DL, SectionKind Kind, const Constant *C) const {
|
||||||
const Constant *C) const {
|
|
||||||
if (Kind.isMergeableConst4()) return MergeableConst4Section;
|
if (Kind.isMergeableConst4()) return MergeableConst4Section;
|
||||||
if (Kind.isMergeableConst8()) return MergeableConst8Section;
|
if (Kind.isMergeableConst8()) return MergeableConst8Section;
|
||||||
if (Kind.isMergeableConst16()) return MergeableConst16Section;
|
if (Kind.isMergeableConst16()) return MergeableConst16Section;
|
||||||
|
@ -33,7 +33,7 @@ static const unsigned CodeModelLargeSize = 256;
|
|||||||
Mangler &Mang,
|
Mangler &Mang,
|
||||||
const TargetMachine &TM) const override;
|
const TargetMachine &TM) const override;
|
||||||
|
|
||||||
MCSection *getSectionForConstant(SectionKind Kind,
|
MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
|
||||||
const Constant *C) const override;
|
const Constant *C) const override;
|
||||||
};
|
};
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user