From 302041d5c9e43e0acb3e477e04b0250f6f6477c6 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 8 Aug 2009 20:14:13 +0000 Subject: sink getOrCreateSection down into all the object file implementations, now that they create *all* the sections. llvm-svn: 78494 --- llvm/lib/Target/TargetLoweringObjectFile.cpp | 29 ++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'llvm/lib/Target/TargetLoweringObjectFile.cpp') diff --git a/llvm/lib/Target/TargetLoweringObjectFile.cpp b/llvm/lib/Target/TargetLoweringObjectFile.cpp index 6aca6da8afe..e983285f337 100644 --- a/llvm/lib/Target/TargetLoweringObjectFile.cpp +++ b/llvm/lib/Target/TargetLoweringObjectFile.cpp @@ -274,19 +274,18 @@ TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind) const { } -const MCSection *TargetLoweringObjectFile:: -getOrCreateSection(const char *Name, bool isDirective, SectionKind Kind) const { - if (MCSection *S = Ctx->GetSection(Name)) - return S; - return MCSection::Create(Name, isDirective, Kind, *Ctx); -} - - //===----------------------------------------------------------------------===// // ELF //===----------------------------------------------------------------------===// +const MCSection *TargetLoweringObjectFileELF:: +getOrCreateSection(const char *Name, bool isDirective, SectionKind Kind) const { + if (MCSection *S = getContext().GetSection(Name)) + return S; + return MCSection::Create(Name, isDirective, Kind, getContext()); +} + void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx, const TargetMachine &TM) { TargetLoweringObjectFile::Initialize(Ctx, TM); @@ -575,6 +574,13 @@ getSectionForConstant(SectionKind Kind) const { // MachO //===----------------------------------------------------------------------===// +const MCSection *TargetLoweringObjectFileMachO:: +getOrCreateSection(const char *Name, bool isDirective, SectionKind Kind) const { + if (MCSection *S = getContext().GetSection(Name)) + return S; + return MCSection::Create(Name, isDirective, Kind, getContext()); +} + const MCSection *TargetLoweringObjectFileMachO:: getMachOSection(const char *Name, bool isDirective, SectionKind K) { // FOR NOW, Just forward. @@ -788,6 +794,13 @@ shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *Mang) const { // COFF //===----------------------------------------------------------------------===// +const MCSection *TargetLoweringObjectFileCOFF:: +getOrCreateSection(const char *Name, bool isDirective, SectionKind Kind) const { + if (MCSection *S = getContext().GetSection(Name)) + return S; + return MCSection::Create(Name, isDirective, Kind, getContext()); +} + const MCSection *TargetLoweringObjectFileCOFF:: getCOFFSection(const char *Name, bool isDirective, SectionKind K) { return getOrCreateSection(Name, isDirective, K); -- cgit v1.2.3