mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
the 'isWeakForLinker' code is common between functions and globals, hoist it
and simplify some other code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76949 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -77,6 +77,13 @@ const Section*
|
||||
ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
|
||||
SectionKind::Kind Kind = SectionKindForGlobal(GV);
|
||||
|
||||
if (GV->isWeakForLinker()) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
if (const Function *F = dyn_cast<Function>(GV)) {
|
||||
switch (F->getLinkage()) {
|
||||
default: llvm_unreachable("Unknown linkage type!");
|
||||
@@ -86,23 +93,11 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
|
||||
case Function::DLLExportLinkage:
|
||||
case Function::ExternalLinkage:
|
||||
return TextSection;
|
||||
case Function::WeakAnyLinkage:
|
||||
case Function::WeakODRLinkage:
|
||||
case Function::LinkOnceAnyLinkage:
|
||||
case Function::LinkOnceODRLinkage:
|
||||
// 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()) {
|
||||
// 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 {
|
||||
const GlobalVariable *GVar = cast<GlobalVariable>(GV);
|
||||
switch (Kind) {
|
||||
default: llvm_unreachable("Unsuported section kind for global");
|
||||
case SectionKind::Data:
|
||||
case SectionKind::DataRel:
|
||||
return DataRelSection;
|
||||
@@ -128,14 +123,8 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
|
||||
return TLSDataSection;
|
||||
case SectionKind::ThreadBSS:
|
||||
return TLSBSSSection;
|
||||
default:
|
||||
llvm_unreachable("Unsuported section kind for global");
|
||||
}
|
||||
}
|
||||
} else
|
||||
llvm_unreachable("Unsupported global");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/// getSectionForMergableConstant - Given a mergable constant with the
|
||||
|
Reference in New Issue
Block a user