[llvm-commits] [llvm] r53912 - /llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp
Bruno Cardoso Lopes
bruno.cardoso at gmail.com
Tue Jul 22 09:24:21 PDT 2008
Author: bruno
Date: Tue Jul 22 11:24:21 2008
New Revision: 53912
URL: http://llvm.org/viewvc/llvm-project?rev=53912&view=rev
Log:
simplified small section logic
Modified:
llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp
Modified: llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp?rev=53912&r1=53911&r2=53912&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsTargetAsmInfo.cpp Tue Jul 22 11:24:21 2008
@@ -45,45 +45,29 @@
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);
+ SectionKind::Kind K = ELFTargetAsmInfo::SectionKindForGlobal(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;
+ 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*
More information about the llvm-commits
mailing list