diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-07-24 03:49:17 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-07-24 03:49:17 +0000 | 
| commit | 07bd1cd8c5666fd94abeed60a7a24c5e15d30234 (patch) | |
| tree | deabd5324f3c973f11ce07995fc3004f8438b159 /llvm | |
| parent | 30ac7607be10a493078f4cacb40f17836b8e0c25 (diff) | |
| download | bcm5719-llvm-07bd1cd8c5666fd94abeed60a7a24c5e15d30234.tar.gz bcm5719-llvm-07bd1cd8c5666fd94abeed60a7a24c5e15d30234.zip  | |
reduce api exposure: clients shouldn't call SectionKindForGlobal directly.
llvm-svn: 76941
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp | 43 | ||||
| -rw-r--r-- | llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp | 9 | ||||
| -rw-r--r-- | llvm/lib/Target/TargetAsmInfo.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp | 9 | 
4 files changed, 32 insertions, 31 deletions
diff --git a/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index 2c8afadb072..e863043de55 100644 --- a/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -1077,9 +1077,9 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {    if (EmitSpecialLLVMGlobal(GVar)) {      if (Subtarget->isTargetDarwin() &&          TM.getRelocationModel() == Reloc::Static) { -      if (GVar->getName() == "llvm.global_ctors") +      if (GVar->isName("llvm.global_ctors"))          O << ".reference .constructors_used\n"; -      else if (GVar->getName() == "llvm.global_dtors") +      else if (GVar->isName("llvm.global_dtors"))          O << ".reference .destructors_used\n";      }      return; @@ -1098,14 +1098,15 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {    if (Subtarget->isTargetELF())      O << "\t.type " << name << ",%object\n"; +   +  const Section *TheSection = TAI->SectionForGlobal(GVar); +  SwitchToSection(TheSection);    if (C->isNullValue() && !GVar->hasSection() && !GVar->isThreadLocal() && -      !(isDarwin && -        TAI->SectionKindForGlobal(GVar) == SectionKind::RODataMergeStr)) { +      !(isDarwin && TheSection->getFlags() == SectionKind::RODataMergeStr)) {      // FIXME: This seems to be pretty darwin-specific      if (GVar->hasExternalLinkage()) { -      SwitchToSection(TAI->SectionForGlobal(GVar));        if (const char *Directive = TAI->getZeroFillDirective()) {          O << "\t.globl\t" << name << "\n";          O << Directive << "__DATA, __common, " << name << ", " @@ -1147,7 +1148,6 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {              O << ',' << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);          }        } else { -        SwitchToSection(TAI->SectionForGlobal(GVar));          if (GVar->hasLocalLinkage())            O << "\t.local\t" << name << "\n";          O << TAI->getCOMMDirective()  << name << "," << Size; @@ -1162,14 +1162,13 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {        return;      }    } - -  SwitchToSection(TAI->SectionForGlobal(GVar)); +      switch (GVar->getLinkage()) { -   case GlobalValue::CommonLinkage: -   case GlobalValue::LinkOnceAnyLinkage: -   case GlobalValue::LinkOnceODRLinkage: -   case GlobalValue::WeakAnyLinkage: -   case GlobalValue::WeakODRLinkage: +  case GlobalValue::CommonLinkage: +  case GlobalValue::LinkOnceAnyLinkage: +  case GlobalValue::LinkOnceODRLinkage: +  case GlobalValue::WeakAnyLinkage: +  case GlobalValue::WeakODRLinkage:      if (isDarwin) {        O << "\t.globl " << name << "\n"          << "\t.weak_definition " << name << "\n"; @@ -1177,17 +1176,17 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {        O << "\t.weak " << name << "\n";      }      break; -   case GlobalValue::AppendingLinkage: -    // FIXME: appending linkage variables should go into a section of -    // their name or something.  For now, just emit them as external. -   case GlobalValue::ExternalLinkage: +  case GlobalValue::AppendingLinkage: +  // FIXME: appending linkage variables should go into a section of +  // their name or something.  For now, just emit them as external. +  case GlobalValue::ExternalLinkage:      O << "\t.globl " << name << "\n"; -    // FALL THROUGH -   case GlobalValue::PrivateLinkage: -   case GlobalValue::LinkerPrivateLinkage: -   case GlobalValue::InternalLinkage:      break; -   default: +  case GlobalValue::PrivateLinkage: +  case GlobalValue::LinkerPrivateLinkage: +  case GlobalValue::InternalLinkage: +    break; +  default:      llvm_unreachable("Unknown linkage type!");    } diff --git a/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index 3db1ef8b6d3..9c0aa74a34e 100644 --- a/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -874,9 +874,9 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {    // Check to see if this is a special global used by LLVM, if so, emit it.    if (EmitSpecialLLVMGlobal(GVar)) {      if (TM.getRelocationModel() == Reloc::Static) { -      if (GVar->getName() == "llvm.global_ctors") +      if (GVar->isName("llvm.global_ctors"))          O << ".reference .constructors_used\n"; -      else if (GVar->getName() == "llvm.global_dtors") +      else if (GVar->isName("llvm.global_dtors"))          O << ".reference .destructors_used\n";      }      return; @@ -890,13 +890,14 @@ void PPCDarwinAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {    unsigned Size = TD->getTypeAllocSize(Type);    unsigned Align = TD->getPreferredAlignmentLog(GVar); -  SwitchToSection(TAI->SectionForGlobal(GVar)); +  const Section *TheSection = TAI->SectionForGlobal(GVar); +  SwitchToSection(TheSection);    if (C->isNullValue() && /* FIXME: Verify correct */        !GVar->hasSection() &&        (GVar->hasLocalLinkage() || GVar->hasExternalLinkage() ||         GVar->isWeakForLinker()) && -      TAI->SectionKindForGlobal(GVar) != SectionKind::RODataMergeStr) { +      TheSection->getFlags() != SectionKind::RODataMergeStr) {      if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.      if (GVar->hasExternalLinkage()) { diff --git a/llvm/lib/Target/TargetAsmInfo.cpp b/llvm/lib/Target/TargetAsmInfo.cpp index 89c80091ecc..bf543cc4ec3 100644 --- a/llvm/lib/Target/TargetAsmInfo.cpp +++ b/llvm/lib/Target/TargetAsmInfo.cpp @@ -222,7 +222,7 @@ TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {    }    // Variable either is not constant or thread-local - output to data section. -  return (isThreadLocal ? SectionKind::ThreadData : SectionKind::Data); +  return isThreadLocal ? SectionKind::ThreadData : SectionKind::Data;  }  unsigned diff --git a/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index 1e505a670fe..74145dcfce0 100644 --- a/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -773,9 +773,9 @@ void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {    if (EmitSpecialLLVMGlobal(GVar)) {      if (Subtarget->isTargetDarwin() &&          TM.getRelocationModel() == Reloc::Static) { -      if (GVar->getName() == "llvm.global_ctors") +      if (GVar->isName("llvm.global_ctors"))          O << ".reference .constructors_used\n"; -      else if (GVar->getName() == "llvm.global_dtors") +      else if (GVar->isName("llvm.global_dtors"))          O << ".reference .destructors_used\n";      }      return; @@ -794,11 +794,12 @@ void X86ATTAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {    if (Subtarget->isTargetELF())      O << "\t.type\t" << name << ",@object\n"; -  SwitchToSection(TAI->SectionForGlobal(GVar)); +  const Section *TheSection = TAI->SectionForGlobal(GVar); +  SwitchToSection(TheSection);    if (C->isNullValue() && !GVar->hasSection() &&        !(Subtarget->isTargetDarwin() && -        TAI->SectionKindForGlobal(GVar) == SectionKind::RODataMergeStr)) { +        TheSection->getFlags() == SectionKind::RODataMergeStr)) {      // FIXME: This seems to be pretty darwin-specific      if (GVar->hasExternalLinkage()) {        if (const char *Directive = TAI->getZeroFillDirective()) {  | 

