mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-26 07:34:06 +00:00
simplified small section logic
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53912 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f88a6faf93
commit
c92a0e90b7
@ -45,45 +45,29 @@ MipsTargetAsmInfo::MipsTargetAsmInfo(const MipsTargetMachine &TM):
|
|||||||
SectionFlags::Writeable | SectionFlags::BSS);
|
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
|
SectionKind::Kind
|
||||||
MipsTargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
|
MipsTargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
|
||||||
const TargetData *TD = ETM->getTargetData();
|
SectionKind::Kind K = ELFTargetAsmInfo::SectionKindForGlobal(GV);
|
||||||
const GlobalVariable *GVA = dyn_cast<GlobalVariable>(GV);
|
|
||||||
|
|
||||||
if (!GVA)
|
if (K != SectionKind::Data && K != SectionKind::BSS &&
|
||||||
return ELFTargetAsmInfo::SectionKindForGlobal(GV);
|
K != SectionKind::RODataMergeConst)
|
||||||
|
return K;
|
||||||
// if this is a internal constant string, there is a special
|
|
||||||
// section for it, but not in small data/bss.
|
if (isa<GlobalVariable>(GV)) {
|
||||||
if (GVA->hasInitializer() && GV->hasInternalLinkage()) {
|
const TargetData *TD = ETM->getTargetData();
|
||||||
Constant *C = GVA->getInitializer();
|
unsigned Size = TD->getABITypeSize(GV->getType()->getElementType());
|
||||||
const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
|
unsigned Threshold =
|
||||||
if (CVA && CVA->isCString())
|
MipsTM->getSubtarget<MipsSubtarget>().getSSectionThreshold();
|
||||||
return ELFTargetAsmInfo::SectionKindForGlobal(GV);
|
|
||||||
|
if (Size > 0 && Size <= Threshold) {
|
||||||
|
if (K == SectionKind::BSS)
|
||||||
|
return SectionKind::SmallBSS;
|
||||||
|
else
|
||||||
|
return SectionKind::SmallData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Type *Ty = GV->getType()->getElementType();
|
return K;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ELFTargetAsmInfo::SectionKindForGlobal(GV);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Section*
|
const Section*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user