diff --git a/llvm/include/llvm/Target/DarwinTargetAsmInfo.h b/llvm/include/llvm/Target/DarwinTargetAsmInfo.h index edce64096a97..a6f48e1ea3c7 100644 --- a/llvm/include/llvm/Target/DarwinTargetAsmInfo.h +++ b/llvm/include/llvm/Target/DarwinTargetAsmInfo.h @@ -45,7 +45,6 @@ namespace llvm { getSectionForMergableConstant(uint64_t Size, unsigned ReloInfo) const; private: - const Section* MergeableConstSection(const Type *Ty) const; const Section* MergeableStringSection(const GlobalVariable *GV) const; }; } diff --git a/llvm/include/llvm/Target/ELFTargetAsmInfo.h b/llvm/include/llvm/Target/ELFTargetAsmInfo.h index c06a5a9f2873..dd311c3116dd 100644 --- a/llvm/include/llvm/Target/ELFTargetAsmInfo.h +++ b/llvm/include/llvm/Target/ELFTargetAsmInfo.h @@ -42,7 +42,6 @@ namespace llvm { const Section* DataRelROLocalSection; private: - const Section* MergeableConstSection(const Type *Ty) const; const Section* MergeableStringSection(const GlobalVariable *GV) const; }; } diff --git a/llvm/lib/Target/DarwinTargetAsmInfo.cpp b/llvm/lib/Target/DarwinTargetAsmInfo.cpp index ad9dd6884f48..bc2189e1ef0f 100644 --- a/llvm/lib/Target/DarwinTargetAsmInfo.cpp +++ b/llvm/lib/Target/DarwinTargetAsmInfo.cpp @@ -131,31 +131,33 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { bool isNonStatic = TM.getRelocationModel() != Reloc::Static; switch (Kind) { - case SectionKind::Text: + case SectionKind::Text: if (isWeak) return TextCoalSection; else return TextSection; - case SectionKind::Data: - case SectionKind::ThreadData: - case SectionKind::BSS: - case SectionKind::ThreadBSS: + case SectionKind::Data: + case SectionKind::ThreadData: + case SectionKind::BSS: + case SectionKind::ThreadBSS: if (cast(GV)->isConstant()) return (isWeak ? ConstDataCoalSection : ConstDataSection); else return (isWeak ? DataCoalSection : DataSection); - case SectionKind::ROData: + case SectionKind::ROData: return (isWeak ? ConstDataCoalSection : (isNonStatic ? ConstDataSection : getReadOnlySection())); - case SectionKind::RODataMergeStr: + case SectionKind::RODataMergeStr: return (isWeak ? ConstTextCoalSection : MergeableStringSection(cast(GV))); - case SectionKind::RODataMergeConst: + case SectionKind::RODataMergeConst: { if (isWeak) return ConstDataCoalSection; - return MergeableConstSection(cast(GV) - ->getInitializer()->getType()); - default: + const Type *Ty = cast(GV)->getInitializer()->getType(); + const TargetData *TD = TM.getTargetData(); + return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0); + } + default: llvm_unreachable("Unsuported section kind for global"); } @@ -179,12 +181,6 @@ DarwinTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const { return getReadOnlySection(); } -const Section* -DarwinTargetAsmInfo::MergeableConstSection(const Type *Ty) const { - const TargetData *TD = TM.getTargetData(); - return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0); -} - const Section * DarwinTargetAsmInfo::getSectionForMergableConstant(uint64_t Size, unsigned ReloInfo) const { diff --git a/llvm/lib/Target/ELFTargetAsmInfo.cpp b/llvm/lib/Target/ELFTargetAsmInfo.cpp index fe006a3c6072..cf4e3a2f1484 100644 --- a/llvm/lib/Target/ELFTargetAsmInfo.cpp +++ b/llvm/lib/Target/ELFTargetAsmInfo.cpp @@ -121,8 +121,11 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { return getReadOnlySection(); case SectionKind::RODataMergeStr: return MergeableStringSection(GVar); - case SectionKind::RODataMergeConst: - return MergeableConstSection(GVar->getInitializer()->getType()); + case SectionKind::RODataMergeConst: { + const Type *Ty = GVar->getInitializer()->getType(); + const TargetData *TD = TM.getTargetData(); + return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0); + } case SectionKind::ThreadData: // ELF targets usually support TLS stuff return TLSDataSection; @@ -165,12 +168,6 @@ ELFTargetAsmInfo::getSectionForMergableConstant(uint64_t Size, } -const Section* -ELFTargetAsmInfo::MergeableConstSection(const Type *Ty) const { - const TargetData *TD = TM.getTargetData(); - return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0); -} - const Section* ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const { const TargetData *TD = TM.getTargetData();