X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FDarwinTargetAsmInfo.cpp;h=cc05c09c5170a1b401706e4317e49f11410b98de;hb=0a0e68a7eac0513505aff3079e2d5d6864e51895;hp=7de890036569f03faf86665263ebdc311e8238a7;hpb=00181a33d87d0c7676547d979b2faa1c08c91732;p=oota-llvm.git diff --git a/lib/Target/DarwinTargetAsmInfo.cpp b/lib/Target/DarwinTargetAsmInfo.cpp index 7de89003656..cc05c09c517 100644 --- a/lib/Target/DarwinTargetAsmInfo.cpp +++ b/lib/Target/DarwinTargetAsmInfo.cpp @@ -24,8 +24,8 @@ using namespace llvm; -DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) { - DTM = &TM; +DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) + : TargetAsmInfo(TM) { CStringSection_ = getUnnamedSection("\t.cstring", SectionFlags::Mergeable | SectionFlags::Strings); @@ -43,6 +43,8 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const TargetMachine &TM) { TextCoalSection = getNamedSection("\t__TEXT,__textcoal_nt,coalesced,pure_instructions", SectionFlags::Code); + ConstTextCoalSection = getNamedSection("\t__TEXT,__const_coal,coalesced", + SectionFlags::None); ConstDataCoalSection = getNamedSection("\t__DATA,__const_coal,coalesced", SectionFlags::None); ConstDataSection = getUnnamedSection(".const_data", SectionFlags::None); @@ -59,7 +61,7 @@ DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV, Mangler *Mang) const { if (GV==0) return false; - if (GV->hasInternalLinkage() && !isa(GV) && + if (GV->hasLocalLinkage() && !isa(GV) && ((strlen(getPrivateGlobalPrefix()) != 0 && Mang->getValueName(GV).substr(0,strlen(getPrivateGlobalPrefix())) == getPrivateGlobalPrefix()) || @@ -73,8 +75,8 @@ DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV, const Section* DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { SectionKind::Kind Kind = SectionKindForGlobal(GV); - bool isWeak = GV->isWeakForLinker(); - bool isNonStatic = (DTM->getRelocationModel() != Reloc::Static); + bool isWeak = GV->mayBeOverridden(); + bool isNonStatic = TM.getRelocationModel() != Reloc::Static; switch (Kind) { case SectionKind::Text: @@ -95,7 +97,7 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { (isNonStatic ? ConstDataSection : getReadOnlySection())); case SectionKind::RODataMergeStr: return (isWeak ? - ConstDataCoalSection : + ConstTextCoalSection : MergeableStringSection(cast(GV))); case SectionKind::RODataMergeConst: return (isWeak ? @@ -106,17 +108,17 @@ DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { } // FIXME: Do we have any extra special weird cases? + return NULL; } const Section* DarwinTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const { - const TargetData *TD = DTM->getTargetData(); + const TargetData *TD = TM.getTargetData(); Constant *C = cast(GV)->getInitializer(); - const Type *Type = cast(C)->getType()->getElementType(); + const Type *Ty = cast(C->getType())->getElementType(); - unsigned Size = TD->getABITypeSize(Type); + unsigned Size = TD->getTypePaddedSize(Ty); if (Size) { - const TargetData *TD = DTM->getTargetData(); unsigned Align = TD->getPreferredAlignment(GV); if (Align <= 32) return getCStringSection_(); @@ -134,9 +136,9 @@ DarwinTargetAsmInfo::MergeableConstSection(const GlobalVariable *GV) const { inline const Section* DarwinTargetAsmInfo::MergeableConstSection(const Type *Ty) const { - const TargetData *TD = DTM->getTargetData(); + const TargetData *TD = TM.getTargetData(); - unsigned Size = TD->getABITypeSize(Ty); + unsigned Size = TD->getTypePaddedSize(Ty); if (Size == 4) return FourByteConstantSection; else if (Size == 8) @@ -153,7 +155,7 @@ DarwinTargetAsmInfo::SelectSectionForMachineConst(const Type *Ty) const { // Handle weird special case, when compiling PIC stuff. if (S == getReadOnlySection() && - DTM->getRelocationModel() != Reloc::Static) + TM.getRelocationModel() != Reloc::Static) return ConstDataSection; return S;