X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FELFTargetAsmInfo.cpp;h=624b95c7b6c162e643545d7665d0c968a507c83a;hb=0a0e68a7eac0513505aff3079e2d5d6864e51895;hp=7457e0827c31cf37be10b62ec6cdb5b6131e2808;hpb=00181a33d87d0c7676547d979b2faa1c08c91732;p=oota-llvm.git diff --git a/lib/Target/ELFTargetAsmInfo.cpp b/lib/Target/ELFTargetAsmInfo.cpp index 7457e0827c3..624b95c7b6c 100644 --- a/lib/Target/ELFTargetAsmInfo.cpp +++ b/lib/Target/ELFTargetAsmInfo.cpp @@ -24,8 +24,8 @@ using namespace llvm; -ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM) { - ETM = &TM; +ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM) + : TargetAsmInfo(TM) { BSSSection_ = getUnnamedSection("\t.bss", SectionFlags::Writeable | SectionFlags::BSS); @@ -44,6 +44,7 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { if (const Function *F = dyn_cast(GV)) { switch (F->getLinkage()) { default: assert(0 && "Unknown linkage type!"); + case Function::PrivateLinkage: case Function::InternalLinkage: case Function::DLLExportLinkage: case Function::ExternalLinkage: @@ -55,7 +56,7 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { return getNamedSection(Name.c_str(), Flags); } } else if (const GlobalVariable *GVar = dyn_cast(GV)) { - if (GVar->isWeakForLinker()) { + if (GVar->mayBeOverridden()) { std::string Name = UniqueSectionForGlobal(GVar, Kind); unsigned Flags = SectionFlagsForGlobal(GVar, Name.c_str()); return getNamedSection(Name.c_str(), Flags); @@ -86,6 +87,8 @@ ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { } } else assert(0 && "Unsupported global"); + + return NULL; } const Section* @@ -102,12 +105,12 @@ ELFTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const { inline const Section* ELFTargetAsmInfo::MergeableConstSection(const Type *Ty) const { - const TargetData *TD = ETM->getTargetData(); + const TargetData *TD = TM.getTargetData(); // FIXME: string here is temporary, until stuff will fully land in. // We cannot use {Four,Eight,Sixteen}ByteConstantSection here, since it's // currently directly used by asmprinter. - unsigned Size = TD->getABITypeSize(Ty); + unsigned Size = TD->getTypePaddedSize(Ty); if (Size == 4 || Size == 8 || Size == 16) { std::string Name = ".rodata.cst" + utostr(Size); @@ -121,17 +124,15 @@ ELFTargetAsmInfo::MergeableConstSection(const Type *Ty) const { const Section* ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const { - const TargetData *TD = ETM->getTargetData(); + const TargetData *TD = TM.getTargetData(); Constant *C = cast(GV)->getInitializer(); - const ConstantArray *CVA = cast(C); - const Type *Ty = CVA->getType()->getElementType(); + const Type *Ty = cast(C->getType())->getElementType(); - unsigned Size = TD->getABITypeSize(Ty); + unsigned Size = TD->getTypePaddedSize(Ty); if (Size <= 16) { assert(getCStringSection() && "Should have string section prefix"); // We also need alignment here - const TargetData *TD = ETM->getTargetData(); unsigned Align = TD->getPrefTypeAlignment(Ty); if (Align < Size) Align = Size; @@ -183,4 +184,3 @@ std::string ELFTargetAsmInfo::printSectionFlags(unsigned flags) const { return Flags; } -