we already know the sectionkind when invoking SelectSectionForGlobal,

pass it in instead of recomputing it.

llvm-svn: 76990
This commit is contained in:
Chris Lattner 2009-07-24 18:42:53 +00:00
parent bf9ac228f7
commit 73f6651439
8 changed files with 20 additions and 17 deletions

View File

@ -34,7 +34,8 @@ namespace llvm {
const Section* SixteenByteConstantSection; const Section* SixteenByteConstantSection;
explicit DarwinTargetAsmInfo(const TargetMachine &TM); 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, virtual bool emitUsedDirectiveFor(const GlobalValue *GV,
Mangler *Mang) const; Mangler *Mang) const;

View File

@ -38,7 +38,8 @@ namespace llvm {
virtual unsigned getFlagsForNamedSection(const char *Section) const; virtual unsigned getFlagsForNamedSection(const char *Section) const;
SectionKind::Kind SectionKindForGlobal(const GlobalValue *GV) 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; virtual std::string printSectionFlags(unsigned flags) const;
const Section* DataRelSection; const Section* DataRelSection;

View File

@ -619,7 +619,8 @@ namespace llvm {
virtual std::string printSectionFlags(unsigned flags) const { return ""; } virtual std::string printSectionFlags(unsigned flags) const { return ""; }
// FIXME: Eliminate this. // 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 /// getSLEB128Size - Compute the number of bytes required for a signed
/// leb128 value. /// leb128 value.

View File

@ -125,8 +125,8 @@ bool DarwinTargetAsmInfo::emitUsedDirectiveFor(const GlobalValue* GV,
} }
const Section* const Section*
DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { DarwinTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
SectionKind::Kind Kind = SectionKindForGlobal(GV); SectionKind::Kind Kind) const {
bool isWeak = GV->isWeakForLinker(); bool isWeak = GV->isWeakForLinker();
bool isNonStatic = TM.getRelocationModel() != Reloc::Static; bool isNonStatic = TM.getRelocationModel() != Reloc::Static;

View File

@ -74,9 +74,8 @@ ELFTargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
} }
const Section* const Section*
ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
SectionKind::Kind Kind = SectionKindForGlobal(GV); SectionKind::Kind Kind) const {
if (const Function *F = dyn_cast<Function>(GV)) { if (const Function *F = dyn_cast<Function>(GV)) {
switch (F->getLinkage()) { switch (F->getLinkage()) {
default: llvm_unreachable("Unknown linkage type!"); default: llvm_unreachable("Unknown linkage type!");

View File

@ -186,14 +186,15 @@ PIC16TargetAsmInfo::getSectionForAuto(const GlobalVariable *GV) const {
// Override default implementation to put the true globals into // Override default implementation to put the true globals into
// multiple data sections if required. // multiple data sections if required.
const Section* 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 // We select the section based on the initializer here, so it really
// has to be a GlobalVariable. // has to be a GlobalVariable.
const GlobalVariable *GV = dyn_cast<GlobalVariable>(GV1); const GlobalVariable *GV = dyn_cast<GlobalVariable>(GV1);
if (!GV) if (!GV)
return TargetAsmInfo::SelectSectionForGlobal(GV1); return TargetAsmInfo::SelectSectionForGlobal(GV1, Kind);
// Record Exteranl Var Decls. // Record External Var Decls.
if (GV->isDeclaration()) { if (GV->isDeclaration()) {
ExternalVarDecls->Items.push_back(GV); ExternalVarDecls->Items.push_back(GV);
return ExternalVarDecls->S_; return ExternalVarDecls->S_;
@ -225,7 +226,7 @@ PIC16TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV1) const {
return getROSectionForGlobal(GV); return getROSectionForGlobal(GV);
// Else let the default implementation take care of it. // Else let the default implementation take care of it.
return TargetAsmInfo::SelectSectionForGlobal(GV); return TargetAsmInfo::SelectSectionForGlobal(GV, Kind);
} }
PIC16TargetAsmInfo::~PIC16TargetAsmInfo() { PIC16TargetAsmInfo::~PIC16TargetAsmInfo() {

View File

@ -74,7 +74,8 @@ namespace llvm {
const Section *getROSectionForGlobal(const GlobalVariable *GV) const; const Section *getROSectionForGlobal(const GlobalVariable *GV) const;
const Section *CreateROSectionForGlobal(const GlobalVariable *GV, const Section *CreateROSectionForGlobal(const GlobalVariable *GV,
std::string Addr = "") const; 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 Section *CreateSectionForGlobal(const GlobalVariable *GV,
const std::string &Addr = "") const; const std::string &Addr = "") const;
public: public:

View File

@ -300,14 +300,13 @@ const Section *TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
} }
// Use default section depending on the 'type' of global // 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. // Lame default implementation. Calculate the section name for global.
const Section* const Section*
TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV) const { TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
SectionKind::Kind Kind = SectionKindForGlobal(GV); SectionKind::Kind Kind) const {
if (Kind == SectionKind::Text) if (Kind == SectionKind::Text)
return getTextSection(); return getTextSection();