X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FTargetAsmInfo.cpp;h=d687e2f44cfd7787a2b541d66fe0ade02550f762;hb=c94ebef1b1ea6dda54494a0a0eafc96ab685a531;hp=03fd326fa497b5cdb0215d80d89d7be44a34db73;hpb=32b952a2a60d1091e0e17bb6ce788cd1d41e6f8b;p=oota-llvm.git diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp index 03fd326fa49..d687e2f44cf 100644 --- a/lib/Target/TargetAsmInfo.cpp +++ b/lib/Target/TargetAsmInfo.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Constants.h" +#include "llvm/DerivedTypes.h" #include "llvm/GlobalVariable.h" #include "llvm/Function.h" #include "llvm/Module.h" @@ -85,6 +86,7 @@ void TargetAsmInfo::fillDefaultValues() { COMMDirective = "\t.comm\t"; COMMDirectiveTakesAlignment = true; HasDotTypeDotSizeDirective = true; + HasSingleParameterDotFile = true; UsedDirective = 0; WeakRefDirective = 0; WeakDefDirective = 0; @@ -98,6 +100,8 @@ void TargetAsmInfo::fillDefaultValues() { SupportsDebugInformation = false; SupportsExceptionHandling = false; DwarfRequiresFrameSection = true; + SupportsMacInfoSection = true; + NonLocalEHFrameLabel = false; GlobalEHDirective = 0; SupportsWeakOmittedEHFrame = true; DwarfSectionOffsetDirective = 0; @@ -119,11 +123,8 @@ void TargetAsmInfo::fillDefaultValues() { DataSection = getUnnamedSection("\t.data", SectionFlags::Writeable); } -TargetAsmInfo::TargetAsmInfo() { - fillDefaultValues(); -} - -TargetAsmInfo::TargetAsmInfo(const TargetMachine &TM) { +TargetAsmInfo::TargetAsmInfo(const TargetMachine &tm) + : TM(tm) { fillDefaultValues(); } @@ -170,6 +171,25 @@ static bool isSuitableForBSS(const GlobalVariable *GV) { return (C->isNullValue() && !GV->isConstant() && !NoZerosInBSS); } +static bool isConstantString(const Constant *C) { + // First check: is we have constant array of i8 terminated with zero + const ConstantArray *CVA = dyn_cast(C); + // Check, if initializer is a null-terminated string + if (CVA && CVA->isCString()) + return true; + + // Another possibility: [1 x i8] zeroinitializer + if (isa(C)) { + if (const ArrayType *Ty = dyn_cast(C->getType())) { + return (Ty->getElementType() == Type::Int8Ty && + Ty->getNumElements() == 1); + } + } + + return false; +} + + SectionKind::Kind TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const { // Early exit - functions should be always in text sections. @@ -191,9 +211,8 @@ TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const { if (C->ContainsRelocations()) return SectionKind::ROData; else { - const ConstantArray *CVA = dyn_cast(C); // Check, if initializer is a null-terminated string - if (CVA && CVA->isCString()) + if (isConstantString(C)) return SectionKind::RODataMergeStr; else return SectionKind::RODataMergeConst; @@ -240,7 +259,7 @@ TargetAsmInfo::SectionFlagsForGlobal(const GlobalValue *GV, assert(0 && "Unexpected section kind!"); } - if (GV->isWeakForLinker()) + if (GV->mayBeOverridden()) Flags |= SectionFlags::Linkonce; } @@ -291,7 +310,7 @@ const Section* TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { SectionKind::Kind Kind = SectionKindForGlobal(GV); - if (GV->isWeakForLinker()) { + if (GV->mayBeOverridden()) { std::string Name = UniqueSectionForGlobal(GV, Kind); unsigned Flags = SectionFlagsForGlobal(GV, Name.c_str()); return getNamedSection(Name.c_str(), Flags); @@ -341,6 +360,7 @@ TargetAsmInfo::UniqueSectionForGlobal(const GlobalValue* GV, default: assert(0 && "Unknown section kind"); } + return NULL; } const Section*