[llvm-commits] [llvm] r76953 - in /llvm/trunk/lib/Target: DarwinTargetAsmInfo.cpp ELFTargetAsmInfo.cpp TargetAsmInfo.cpp
Chris Lattner
sabre at nondot.org
Thu Jul 23 22:10:27 PDT 2009
Author: lattner
Date: Fri Jul 24 00:10:25 2009
New Revision: 76953
URL: http://llvm.org/viewvc/llvm-project?rev=76953&view=rev
Log:
hoist section name uniquing logic up to the top-level SectionForGlobal
implementation, eliminating a dupe.
Modified:
llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp
llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp
llvm/trunk/lib/Target/TargetAsmInfo.cpp
Modified: llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp?rev=76953&r1=76952&r2=76953&view=diff
==============================================================================
--- llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp Fri Jul 24 00:10:25 2009
@@ -134,16 +134,15 @@
case SectionKind::Text:
if (isWeak)
return TextCoalSection;
- else
- return TextSection;
+ return TextSection;
case SectionKind::Data:
case SectionKind::ThreadData:
case SectionKind::BSS:
case SectionKind::ThreadBSS:
if (cast<GlobalVariable>(GV)->isConstant())
- return (isWeak ? ConstDataCoalSection : ConstDataSection);
- else
- return (isWeak ? DataCoalSection : DataSection);
+ return isWeak ? ConstDataCoalSection : ConstDataSection;
+ return isWeak ? DataCoalSection : DataSection;
+
case SectionKind::ROData:
return (isWeak ? ConstDataCoalSection :
(isNonStatic ? ConstDataSection : getReadOnlySection()));
Modified: llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp?rev=76953&r1=76952&r2=76953&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/ELFTargetAsmInfo.cpp Fri Jul 24 00:10:25 2009
@@ -77,15 +77,6 @@
ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const {
SectionKind::Kind Kind = SectionKindForGlobal(GV);
- if (GV->isWeakForLinker()) {
- if (const char *Prefix = getSectionPrefixForUniqueGlobal(Kind)) {
- // FIXME: Use mangler interface (PR4584).
- std::string Name = Prefix+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!");
Modified: llvm/trunk/lib/Target/TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetAsmInfo.cpp?rev=76953&r1=76952&r2=76953&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Fri Jul 24 00:10:25 2009
@@ -295,6 +295,18 @@
return getNamedSection(GV->getSection().c_str(), Flags);
}
+ // If this global is linkonce/weak and the target handles this by emitting it
+ // into a 'uniqued' section name, create and return the section now.
+ if (GV->isWeakForLinker()) {
+ if (const char *Prefix =
+ getSectionPrefixForUniqueGlobal(SectionKindForGlobal(GV))) {
+ // FIXME: Use mangler interface (PR4584).
+ std::string Name = Prefix+GV->getName();
+ unsigned Flags = SectionFlagsForGlobal(GV, Name.c_str());
+ return getNamedSection(Name.c_str(), Flags);
+ }
+ }
+
// Use default section depending on the 'type' of global
return SelectSectionForGlobal(GV);
}
@@ -304,19 +316,16 @@
TargetAsmInfo::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);
- } else {
- if (Kind == SectionKind::Text)
- return getTextSection();
- else if (isBSS(Kind) && getBSSSection_())
- return getBSSSection_();
- else if (getReadOnlySection() && SectionKind::isReadOnly(Kind))
- return getReadOnlySection();
- }
+ if (Kind == SectionKind::Text)
+ return getTextSection();
+
+ if (isBSS(Kind))
+ if (const Section *S = getBSSSection_())
+ return S;
+
+ if (SectionKind::isReadOnly(Kind))
+ if (const Section *S = getReadOnlySection())
+ return S;
return getDataSection();
}
@@ -352,7 +361,6 @@
case SectionKind::ThreadData: return ".gnu.linkonce.td.";
case SectionKind::ThreadBSS: return ".gnu.linkonce.tb.";
}
- return NULL;
}
const Section *TargetAsmInfo::getNamedSection(const char *Name, unsigned Flags,
More information about the llvm-commits
mailing list