From f20f250b6f1b3d4c873c4f6fa368a6ab5ace39b7 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 24 Jul 2009 18:42:53 +0000 Subject: [PATCH] we already know the sectionkind when invoking SelectSectionForGlobal, pass it in instead of recomputing it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76990 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/DarwinTargetAsmInfo.h | 3 ++- include/llvm/Target/ELFTargetAsmInfo.h | 3 ++- include/llvm/Target/TargetAsmInfo.h | 3 ++- lib/Target/DarwinTargetAsmInfo.cpp | 4 ++-- lib/Target/ELFTargetAsmInfo.cpp | 5 ++--- lib/Target/PIC16/PIC16TargetAsmInfo.cpp | 9 +++++---- lib/Target/PIC16/PIC16TargetAsmInfo.h | 3 ++- lib/Target/TargetAsmInfo.cpp | 7 +++---- 8 files changed, 20 insertions(+), 17 deletions(-) diff --git a/include/llvm/Target/DarwinTargetAsmInfo.h b/include/llvm/Target/DarwinTargetAsmInfo.h index 082acbfe378..e1662dd8690 100644 --- a/include/llvm/Target/DarwinTargetAsmInfo.h +++ b/include/llvm/Target/DarwinTargetAsmInfo.h @@ -34,7 +34,8 @@ namespace llvm { const Section* SixteenByteConstantSection; explicit DarwinTargetAsmInfo(const TargetMachine &TM); - virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const; + virtual const Section* SelectSectionForGlobal(const GlobalValue *GV, + SectionKind::Kind Kind) const; virtual bool emitUsedDirectiveFor(const GlobalValue *GV, Mangler *Mang) const; diff --git a/include/llvm/Target/ELFTargetAsmInfo.h b/include/llvm/Target/ELFTargetAsmInfo.h index 65a919af690..63e3acd50d7 100644 --- a/include/llvm/Target/ELFTargetAsmInfo.h +++ b/include/llvm/Target/ELFTargetAsmInfo.h @@ -38,7 +38,8 @@ namespace llvm { virtual unsigned getFlagsForNamedSection(const char *Section) const; SectionKind::Kind SectionKindForGlobal(const GlobalValue *GV) const; - virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const; + virtual const Section* SelectSectionForGlobal(const GlobalValue *GV, + SectionKind::Kind Kind) const; virtual std::string printSectionFlags(unsigned flags) const; const Section* DataRelSection; diff --git a/include/llvm/Target/TargetAsmInfo.h b/include/llvm/Target/TargetAsmInfo.h index 419f5fbe629..a34911691a8 100644 --- a/include/llvm/Target/TargetAsmInfo.h +++ b/include/llvm/Target/TargetAsmInfo.h @@ -619,7 +619,8 @@ namespace llvm { virtual std::string printSectionFlags(unsigned flags) const { return ""; } // FIXME: Eliminate this. - virtual const Section* SelectSectionForGlobal(const GlobalValue *GV) const; + virtual const Section* SelectSectionForGlobal(const GlobalValue *GV, + SectionKind::Kind Kind) const; /// getSLEB128Size - Compute the number of bytes required for a signed /// leb128 value. diff --git a/lib/Target/DarwinTargetAsmInfo.cpp b/lib/Target/DarwinTargetAsmInfo.cpp index c25040ca600..27714f21ea0 100644 --- a/lib/Target/DarwinTargetAsmInfo.cpp +++ b/lib/Target/DarwinTargetAsmInfo.cpp @@ -125,8 +125,8 @@ bool DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV, } const Section* -DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { - SectionKind::Kind Kind = SectionKindForGlobal(GV); +DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV, + SectionKind::Kind Kind) const { bool isWeak = GV->isWeakForLinker(); bool isNonStatic = TM.getRelocationModel() != Reloc::Static; diff --git a/lib/Target/ELFTargetAsmInfo.cpp b/lib/Target/ELFTargetAsmInfo.cpp index 6ab9efb4899..40b766294f0 100644 --- a/lib/Target/ELFTargetAsmInfo.cpp +++ b/lib/Target/ELFTargetAsmInfo.cpp @@ -74,9 +74,8 @@ ELFTargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const { } const Section* -ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { - SectionKind::Kind Kind = SectionKindForGlobal(GV); - +ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV, + SectionKind::Kind Kind) const { if (const Function *F = dyn_cast(GV)) { switch (F->getLinkage()) { default: llvm_unreachable("Unknown linkage type!"); diff --git a/lib/Target/PIC16/PIC16TargetAsmInfo.cpp b/lib/Target/PIC16/PIC16TargetAsmInfo.cpp index fedb0b82ca3..6f4b0c5c8d8 100644 --- a/lib/Target/PIC16/PIC16TargetAsmInfo.cpp +++ b/lib/Target/PIC16/PIC16TargetAsmInfo.cpp @@ -186,14 +186,15 @@ PIC16TargetAsmInfo::getSectionForAuto(const GlobalVariable *GV) const { // Override default implementation to put the true globals into // multiple data sections if required. const Section* -PIC16TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV1) const { +PIC16TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV1, + SectionKind::Kind Kind) const { // We select the section based on the initializer here, so it really // has to be a GlobalVariable. const GlobalVariable *GV = dyn_cast(GV1); if (!GV) - return TargetAsmInfo::SelectSectionForGlobal(GV1); + return TargetAsmInfo::SelectSectionForGlobal(GV1, Kind); - // Record Exteranl Var Decls. + // Record External Var Decls. if (GV->isDeclaration()) { ExternalVarDecls->Items.push_back(GV); return ExternalVarDecls->S_; @@ -225,7 +226,7 @@ PIC16TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV1) const { return getROSectionForGlobal(GV); // Else let the default implementation take care of it. - return TargetAsmInfo::SelectSectionForGlobal(GV); + return TargetAsmInfo::SelectSectionForGlobal(GV, Kind); } PIC16TargetAsmInfo::~PIC16TargetAsmInfo() { diff --git a/lib/Target/PIC16/PIC16TargetAsmInfo.h b/lib/Target/PIC16/PIC16TargetAsmInfo.h index 9b934b039d9..d9259aa6d45 100644 --- a/lib/Target/PIC16/PIC16TargetAsmInfo.h +++ b/lib/Target/PIC16/PIC16TargetAsmInfo.h @@ -74,7 +74,8 @@ namespace llvm { const Section *getROSectionForGlobal(const GlobalVariable *GV) const; const Section *CreateROSectionForGlobal(const GlobalVariable *GV, std::string Addr = "") const; - virtual const Section *SelectSectionForGlobal(const GlobalValue *GV) const; + virtual const Section *SelectSectionForGlobal(const GlobalValue *GV, + SectionKind::Kind Kind) const; const Section *CreateSectionForGlobal(const GlobalVariable *GV, const std::string &Addr = "") const; public: diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp index 1ed9a716b4d..9893bf9b7aa 100644 --- a/lib/Target/TargetAsmInfo.cpp +++ b/lib/Target/TargetAsmInfo.cpp @@ -300,14 +300,13 @@ const Section *TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const { } // Use default section depending on the 'type' of global - return SelectSectionForGlobal(GV); + return SelectSectionForGlobal(GV, Kind); } // Lame default implementation. Calculate the section name for global. const Section* -TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { - SectionKind::Kind Kind = SectionKindForGlobal(GV); - +TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV, + SectionKind::Kind Kind) const { if (Kind == SectionKind::Text) return getTextSection(); -- 2.34.1