mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 06:32:24 +00:00
Replace UniqueSectionForGlobal with getSectionPrefixForUniqueGlobal.
The later doesn't depend on any crazy LLVM IR stuff, and this pulls the concatenation of prefix with GV name (the root problem behind PR4584) out one level. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76948 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
837f332372
commit
55acc6807f
@ -35,8 +35,6 @@ namespace llvm {
|
|||||||
|
|
||||||
explicit DarwinTargetAsmInfo(const TargetMachine &TM);
|
explicit DarwinTargetAsmInfo(const TargetMachine &TM);
|
||||||
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const;
|
virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const;
|
||||||
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
|
|
||||||
SectionKind::Kind kind) const;
|
|
||||||
virtual bool emitUsedDirectiveFor(const GlobalValue *GV,
|
virtual bool emitUsedDirectiveFor(const GlobalValue *GV,
|
||||||
Mangler *Mang) const;
|
Mangler *Mang) const;
|
||||||
|
|
||||||
|
@ -579,6 +579,16 @@ namespace llvm {
|
|||||||
getSectionForMergableConstant(uint64_t Size, unsigned ReloInfo) const;
|
getSectionForMergableConstant(uint64_t Size, unsigned ReloInfo) const;
|
||||||
|
|
||||||
|
|
||||||
|
/// getSectionPrefixForUniqueGlobal - Return a string that we should prepend
|
||||||
|
/// onto a global's name in order to get the unique section name for the
|
||||||
|
/// global. This is important for globals that need to be merged across
|
||||||
|
/// translation units.
|
||||||
|
virtual const char *
|
||||||
|
getSectionPrefixForUniqueGlobal(SectionKind::Kind Kind) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// SectionKindForGlobal - This hook allows the target to select proper
|
/// SectionKindForGlobal - This hook allows the target to select proper
|
||||||
/// section kind used for global emission.
|
/// section kind used for global emission.
|
||||||
// FIXME: Eliminate this.
|
// FIXME: Eliminate this.
|
||||||
@ -597,11 +607,6 @@ namespace llvm {
|
|||||||
// FIXME: Eliminate this.
|
// FIXME: Eliminate this.
|
||||||
virtual const Section* SectionForGlobal(const GlobalValue *GV) const;
|
virtual const Section* SectionForGlobal(const GlobalValue *GV) const;
|
||||||
|
|
||||||
// Helper methods for SectionForGlobal
|
|
||||||
// FIXME: Eliminate this.
|
|
||||||
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
|
|
||||||
SectionKind::Kind kind) const;
|
|
||||||
|
|
||||||
const std::string &getSectionFlags(unsigned Flags) const;
|
const std::string &getSectionFlags(unsigned Flags) const;
|
||||||
virtual std::string printSectionFlags(unsigned flags) const { return ""; }
|
virtual std::string printSectionFlags(unsigned flags) const { return ""; }
|
||||||
|
|
||||||
|
@ -204,9 +204,3 @@ DarwinTargetAsmInfo::getSectionForMergableConstant(uint64_t Size,
|
|||||||
return ReadOnlySection; // .const
|
return ReadOnlySection; // .const
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
|
||||||
DarwinTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
|
|
||||||
SectionKind::Kind kind) const {
|
|
||||||
llvm_unreachable("Darwin does not use unique sections");
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
@ -90,13 +90,15 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
|
|||||||
case Function::WeakODRLinkage:
|
case Function::WeakODRLinkage:
|
||||||
case Function::LinkOnceAnyLinkage:
|
case Function::LinkOnceAnyLinkage:
|
||||||
case Function::LinkOnceODRLinkage:
|
case Function::LinkOnceODRLinkage:
|
||||||
std::string Name = UniqueSectionForGlobal(GV, Kind);
|
// FIXME: Use mangler interface (PR4584).
|
||||||
|
std::string Name = getSectionPrefixForUniqueGlobal(Kind)+GV->getName();
|
||||||
unsigned Flags = SectionFlagsForGlobal(GV, Name.c_str());
|
unsigned Flags = SectionFlagsForGlobal(GV, Name.c_str());
|
||||||
return getNamedSection(Name.c_str(), Flags);
|
return getNamedSection(Name.c_str(), Flags);
|
||||||
}
|
}
|
||||||
} else if (const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV)) {
|
} else if (const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV)) {
|
||||||
if (GVar->isWeakForLinker()) {
|
if (GVar->isWeakForLinker()) {
|
||||||
std::string Name = UniqueSectionForGlobal(GVar, Kind);
|
// FIXME: Use mangler interface (PR4584).
|
||||||
|
std::string Name = getSectionPrefixForUniqueGlobal(Kind)+GV->getName();
|
||||||
unsigned Flags = SectionFlagsForGlobal(GVar, Name.c_str());
|
unsigned Flags = SectionFlagsForGlobal(GVar, Name.c_str());
|
||||||
return getNamedSection(Name.c_str(), Flags);
|
return getNamedSection(Name.c_str(), Flags);
|
||||||
} else {
|
} else {
|
||||||
|
@ -305,7 +305,8 @@ TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
|
|||||||
SectionKind::Kind Kind = SectionKindForGlobal(GV);
|
SectionKind::Kind Kind = SectionKindForGlobal(GV);
|
||||||
|
|
||||||
if (GV->isWeakForLinker()) {
|
if (GV->isWeakForLinker()) {
|
||||||
std::string Name = UniqueSectionForGlobal(GV, Kind);
|
// FIXME: Use mangler interface (PR4584).
|
||||||
|
std::string Name = getSectionPrefixForUniqueGlobal(Kind)+GV->getName();
|
||||||
unsigned Flags = SectionFlagsForGlobal(GV, Name.c_str());
|
unsigned Flags = SectionFlagsForGlobal(GV, Name.c_str());
|
||||||
return getNamedSection(Name.c_str(), Flags);
|
return getNamedSection(Name.c_str(), Flags);
|
||||||
} else {
|
} else {
|
||||||
@ -334,34 +335,22 @@ TargetAsmInfo::getSectionForMergableConstant(uint64_t Size,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string
|
const char *
|
||||||
TargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
|
TargetAsmInfo::getSectionPrefixForUniqueGlobal(SectionKind::Kind Kind) const {
|
||||||
SectionKind::Kind Kind) const {
|
|
||||||
switch (Kind) {
|
switch (Kind) {
|
||||||
case SectionKind::Text:
|
default: llvm_unreachable("Unknown section kind");
|
||||||
return ".gnu.linkonce.t." + GV->getNameStr();
|
case SectionKind::Text: return ".gnu.linkonce.t.";
|
||||||
case SectionKind::Data:
|
case SectionKind::Data: return ".gnu.linkonce.d.";
|
||||||
return ".gnu.linkonce.d." + GV->getNameStr();
|
case SectionKind::DataRel: return ".gnu.linkonce.d.rel.";
|
||||||
case SectionKind::DataRel:
|
case SectionKind::DataRelLocal: return ".gnu.linkonce.d.rel.local.";
|
||||||
return ".gnu.linkonce.d.rel" + GV->getNameStr();
|
case SectionKind::DataRelRO: return ".gnu.linkonce.d.rel.ro.";
|
||||||
case SectionKind::DataRelLocal:
|
case SectionKind::DataRelROLocal: return ".gnu.linkonce.d.rel.ro.local.";
|
||||||
return ".gnu.linkonce.d.rel.local" + GV->getNameStr();
|
case SectionKind::BSS: return ".gnu.linkonce.b.";
|
||||||
case SectionKind::DataRelRO:
|
|
||||||
return ".gnu.linkonce.d.rel.ro" + GV->getNameStr();
|
|
||||||
case SectionKind::DataRelROLocal:
|
|
||||||
return ".gnu.linkonce.d.rel.ro.local" + GV->getNameStr();
|
|
||||||
case SectionKind::BSS:
|
|
||||||
return ".gnu.linkonce.b." + GV->getNameStr();
|
|
||||||
case SectionKind::ROData:
|
case SectionKind::ROData:
|
||||||
case SectionKind::RODataMergeConst:
|
case SectionKind::RODataMergeConst:
|
||||||
case SectionKind::RODataMergeStr:
|
case SectionKind::RODataMergeStr: return ".gnu.linkonce.r.";
|
||||||
return ".gnu.linkonce.r." + GV->getNameStr();
|
case SectionKind::ThreadData: return ".gnu.linkonce.td.";
|
||||||
case SectionKind::ThreadData:
|
case SectionKind::ThreadBSS: return ".gnu.linkonce.tb.";
|
||||||
return ".gnu.linkonce.td." + GV->getNameStr();
|
|
||||||
case SectionKind::ThreadBSS:
|
|
||||||
return ".gnu.linkonce.tb." + GV->getNameStr();
|
|
||||||
default:
|
|
||||||
llvm_unreachable("Unknown section kind");
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -256,33 +256,27 @@ X86COFFTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
|
|||||||
Format |= DW_EH_PE_indirect;
|
Format |= DW_EH_PE_indirect;
|
||||||
|
|
||||||
return (Format | DW_EH_PE_pcrel);
|
return (Format | DW_EH_PE_pcrel);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
if (is64Bit &&
|
if (is64Bit &&
|
||||||
(CM == CodeModel::Small ||
|
(CM == CodeModel::Small ||
|
||||||
(CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
|
(CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
|
||||||
return DW_EH_PE_udata4;
|
return DW_EH_PE_udata4;
|
||||||
else
|
|
||||||
return DW_EH_PE_absptr;
|
return DW_EH_PE_absptr;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
const char *X86COFFTargetAsmInfo::
|
||||||
X86COFFTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
|
getSectionPrefixForUniqueGlobal(SectionKind::Kind Kind) const {
|
||||||
SectionKind::Kind kind) const {
|
switch (Kind) {
|
||||||
switch (kind) {
|
default: llvm_unreachable("Unknown section kind");
|
||||||
case SectionKind::Text:
|
case SectionKind::Text: return ".text$linkonce";
|
||||||
return ".text$linkonce" + GV->getName();
|
|
||||||
case SectionKind::Data:
|
case SectionKind::Data:
|
||||||
case SectionKind::BSS:
|
case SectionKind::BSS:
|
||||||
case SectionKind::ThreadData:
|
case SectionKind::ThreadData:
|
||||||
case SectionKind::ThreadBSS:
|
case SectionKind::ThreadBSS: return ".data$linkonce";
|
||||||
return ".data$linkonce" + GV->getName();
|
|
||||||
case SectionKind::ROData:
|
case SectionKind::ROData:
|
||||||
case SectionKind::RODataMergeConst:
|
case SectionKind::RODataMergeConst:
|
||||||
case SectionKind::RODataMergeStr:
|
case SectionKind::RODataMergeStr: return ".rdata$linkonce";
|
||||||
return ".rdata$linkonce" + GV->getName();
|
|
||||||
default:
|
|
||||||
llvm_unreachable("Unknown section kind");
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,8 @@ namespace llvm {
|
|||||||
explicit X86COFFTargetAsmInfo(const X86TargetMachine &TM);
|
explicit X86COFFTargetAsmInfo(const X86TargetMachine &TM);
|
||||||
virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
|
virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
|
||||||
bool Global) const;
|
bool Global) const;
|
||||||
virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
|
virtual const char *
|
||||||
SectionKind::Kind kind) const;
|
getSectionPrefixForUniqueGlobal(SectionKind::Kind kind) const;
|
||||||
virtual std::string printSectionFlags(unsigned flags) const;
|
virtual std::string printSectionFlags(unsigned flags) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user