explicit DarwinTargetAsmInfo(const TargetMachine &TM);
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,
Mangler *Mang) 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
/// section kind used for global emission.
// FIXME: Eliminate this.
// FIXME: Eliminate this.
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;
virtual std::string printSectionFlags(unsigned flags) const { return ""; }
return ReadOnlySection; // .const
}
-std::string
-DarwinTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
- SectionKind::Kind kind) const {
- llvm_unreachable("Darwin does not use unique sections");
- return "";
-}
case Function::WeakODRLinkage:
case Function::LinkOnceAnyLinkage:
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());
return getNamedSection(Name.c_str(), Flags);
}
} else if (const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV)) {
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());
return getNamedSection(Name.c_str(), Flags);
} else {
SectionKind::Kind Kind = SectionKindForGlobal(GV);
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());
return getNamedSection(Name.c_str(), Flags);
} else {
-std::string
-TargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
- SectionKind::Kind Kind) const {
+const char *
+TargetAsmInfo::getSectionPrefixForUniqueGlobal(SectionKind::Kind Kind) const {
switch (Kind) {
- case SectionKind::Text:
- return ".gnu.linkonce.t." + GV->getNameStr();
- case SectionKind::Data:
- return ".gnu.linkonce.d." + GV->getNameStr();
- case SectionKind::DataRel:
- return ".gnu.linkonce.d.rel" + GV->getNameStr();
- case SectionKind::DataRelLocal:
- return ".gnu.linkonce.d.rel.local" + GV->getNameStr();
- 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();
+ default: llvm_unreachable("Unknown section kind");
+ case SectionKind::Text: return ".gnu.linkonce.t.";
+ case SectionKind::Data: return ".gnu.linkonce.d.";
+ case SectionKind::DataRel: return ".gnu.linkonce.d.rel.";
+ case SectionKind::DataRelLocal: return ".gnu.linkonce.d.rel.local.";
+ case SectionKind::DataRelRO: return ".gnu.linkonce.d.rel.ro.";
+ case SectionKind::DataRelROLocal: return ".gnu.linkonce.d.rel.ro.local.";
+ case SectionKind::BSS: return ".gnu.linkonce.b.";
case SectionKind::ROData:
case SectionKind::RODataMergeConst:
- case SectionKind::RODataMergeStr:
- return ".gnu.linkonce.r." + GV->getNameStr();
- case SectionKind::ThreadData:
- return ".gnu.linkonce.td." + GV->getNameStr();
- case SectionKind::ThreadBSS:
- return ".gnu.linkonce.tb." + GV->getNameStr();
- default:
- llvm_unreachable("Unknown section kind");
+ case SectionKind::RODataMergeStr: return ".gnu.linkonce.r.";
+ case SectionKind::ThreadData: return ".gnu.linkonce.td.";
+ case SectionKind::ThreadBSS: return ".gnu.linkonce.tb.";
}
return NULL;
}
Format |= DW_EH_PE_indirect;
return (Format | DW_EH_PE_pcrel);
- } else {
- if (is64Bit &&
- (CM == CodeModel::Small ||
- (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
- return DW_EH_PE_udata4;
- else
- return DW_EH_PE_absptr;
}
+
+ if (is64Bit &&
+ (CM == CodeModel::Small ||
+ (CM == CodeModel::Medium && Reason != DwarfEncoding::Data)))
+ return DW_EH_PE_udata4;
+ return DW_EH_PE_absptr;
}
-std::string
-X86COFFTargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV,
- SectionKind::Kind kind) const {
- switch (kind) {
- case SectionKind::Text:
- return ".text$linkonce" + GV->getName();
- case SectionKind::Data:
- case SectionKind::BSS:
- case SectionKind::ThreadData:
- case SectionKind::ThreadBSS:
- return ".data$linkonce" + GV->getName();
- case SectionKind::ROData:
- case SectionKind::RODataMergeConst:
- case SectionKind::RODataMergeStr:
- return ".rdata$linkonce" + GV->getName();
- default:
- llvm_unreachable("Unknown section kind");
+const char *X86COFFTargetAsmInfo::
+getSectionPrefixForUniqueGlobal(SectionKind::Kind Kind) const {
+ switch (Kind) {
+ default: llvm_unreachable("Unknown section kind");
+ case SectionKind::Text: return ".text$linkonce";
+ case SectionKind::Data:
+ case SectionKind::BSS:
+ case SectionKind::ThreadData:
+ case SectionKind::ThreadBSS: return ".data$linkonce";
+ case SectionKind::ROData:
+ case SectionKind::RODataMergeConst:
+ case SectionKind::RODataMergeStr: return ".rdata$linkonce";
}
return NULL;
}
explicit X86COFFTargetAsmInfo(const X86TargetMachine &TM);
virtual unsigned PreferredEHDataFormat(DwarfEncoding::Target Reason,
bool Global) const;
- virtual std::string UniqueSectionForGlobal(const GlobalValue* GV,
- SectionKind::Kind kind) const;
+ virtual const char *
+ getSectionPrefixForUniqueGlobal(SectionKind::Kind kind) const;
virtual std::string printSectionFlags(unsigned flags) const;
};