summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2008-07-22 16:24:21 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2008-07-22 16:24:21 +0000
commitc92a0e90b73a502d218249b29ff496256e87a596 (patch)
tree37decb2fc02cdbee126565032070faf4be5fb058 /lib
parentf88a6faf930511ce1272c4b1fca1e0ffbd97c4d2 (diff)
downloadllvm-c92a0e90b73a502d218249b29ff496256e87a596.tar.gz
llvm-c92a0e90b73a502d218249b29ff496256e87a596.tar.bz2
llvm-c92a0e90b73a502d218249b29ff496256e87a596.tar.xz
simplified small section logic
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53912 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/Mips/MipsTargetAsmInfo.cpp54
1 files changed, 19 insertions, 35 deletions
diff --git a/lib/Target/Mips/MipsTargetAsmInfo.cpp b/lib/Target/Mips/MipsTargetAsmInfo.cpp
index 4678c3b203..78b5c4aee0 100644
--- a/lib/Target/Mips/MipsTargetAsmInfo.cpp
+++ b/lib/Target/Mips/MipsTargetAsmInfo.cpp
@@ -45,45 +45,29 @@ MipsTargetAsmInfo::MipsTargetAsmInfo(const MipsTargetMachine &TM):
SectionFlags::Writeable | SectionFlags::BSS);
}
-static bool isSuitableForBSS(const GlobalVariable *GV) {
- if (!GV->hasInitializer())
- return true;
-
- // Leave constant zeros in readonly constant sections, so they can be shared
- Constant *C = GV->getInitializer();
- return (C->isNullValue() && !GV->isConstant() && !NoZerosInBSS);
-}
-
SectionKind::Kind
MipsTargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
- const TargetData *TD = ETM->getTargetData();
- const GlobalVariable *GVA = dyn_cast<GlobalVariable>(GV);
-
- if (!GVA)
- return ELFTargetAsmInfo::SectionKindForGlobal(GV);
-
- // if this is a internal constant string, there is a special
- // section for it, but not in small data/bss.
- if (GVA->hasInitializer() && GV->hasInternalLinkage()) {
- Constant *C = GVA->getInitializer();
- const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
- if (CVA && CVA->isCString())
- return ELFTargetAsmInfo::SectionKindForGlobal(GV);
- }
-
- const Type *Ty = GV->getType()->getElementType();
- unsigned Size = TD->getABITypeSize(Ty);
- unsigned Threshold =
- MipsTM->getSubtarget<MipsSubtarget>().getSSectionThreshold();
-
- if (Size > 0 && Size <= Threshold) {
- if (isSuitableForBSS(GVA))
- return SectionKind::SmallBSS;
- else
- return SectionKind::SmallData;
+ SectionKind::Kind K = ELFTargetAsmInfo::SectionKindForGlobal(GV);
+
+ if (K != SectionKind::Data && K != SectionKind::BSS &&
+ K != SectionKind::RODataMergeConst)
+ return K;
+
+ if (isa<GlobalVariable>(GV)) {
+ const TargetData *TD = ETM->getTargetData();
+ unsigned Size = TD->getABITypeSize(GV->getType()->getElementType());
+ unsigned Threshold =
+ MipsTM->getSubtarget<MipsSubtarget>().getSSectionThreshold();
+
+ if (Size > 0 && Size <= Threshold) {
+ if (K == SectionKind::BSS)
+ return SectionKind::SmallBSS;
+ else
+ return SectionKind::SmallData;
+ }
}
- return ELFTargetAsmInfo::SectionKindForGlobal(GV);
+ return K;
}
const Section*