Skip to content

Commit cbc7b26

Browse files
committed
expose SectionKindForGlobal to curious clients, named as
getKindForGlobal. llvm-svn: 78156
1 parent d3a44b5 commit cbc7b26

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

llvm/include/llvm/Target/TargetLoweringObjectFile.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,27 @@ class TargetLoweringObjectFile {
141141
return K;
142142
}
143143

144+
/// getKindForGlobal - Classify the specified global variable into a set of
145+
/// target independent categories embodied in SectionKind.
146+
static SectionKind getKindForGlobal(const GlobalValue *GV,
147+
const TargetMachine &TM);
148+
144149
/// SectionForGlobal - This method computes the appropriate section to emit
145150
/// the specified global variable or function definition. This should not
146151
/// be passed external (or available externally) globals.
147152
const MCSection *SectionForGlobal(const GlobalValue *GV,
148-
Mangler *Mang,
153+
SectionKind Kind, Mangler *Mang,
149154
const TargetMachine &TM) const;
150155

156+
/// SectionForGlobal - This method computes the appropriate section to emit
157+
/// the specified global variable or function definition. This should not
158+
/// be passed external (or available externally) globals.
159+
const MCSection *SectionForGlobal(const GlobalValue *GV,
160+
Mangler *Mang,
161+
const TargetMachine &TM) const {
162+
return SectionForGlobal(GV, getKindForGlobal(GV, TM), Mang, TM);
163+
}
164+
151165
/// getSpecialCasedSectionGlobals - Allow the target to completely override
152166
/// section assignment of a global.
153167
/// FIXME: ELIMINATE this by making PIC16 implement ADDRESS with

llvm/lib/Target/TargetLoweringObjectFile.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,16 @@ static bool IsNullTerminatedString(const Constant *C) {
110110
return false;
111111
}
112112

113-
/// SectionKindForGlobal - This is a top-level target-independent classifier for
113+
/// getKindForGlobal - This is a top-level target-independent classifier for
114114
/// a global variable. Given an global variable and information from TM, it
115115
/// classifies the global in a variety of ways that make various target
116116
/// implementations simpler. The target implementation is free to ignore this
117117
/// extra info of course.
118-
static SectionKind SectionKindForGlobal(const GlobalValue *GV,
119-
const TargetMachine &TM) {
118+
SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV,
119+
const TargetMachine &TM){
120+
assert(!GV->isDeclaration() && !GV->hasAvailableExternallyLinkage() &&
121+
"Can only be used for global definitions");
122+
120123
Reloc::Model ReloModel = TM.getRelocationModel();
121124

122125
// Early exit - functions should be always in text sections.
@@ -227,13 +230,8 @@ static SectionKind SectionKindForGlobal(const GlobalValue *GV,
227230
/// the specified global variable or function definition. This should not
228231
/// be passed external (or available externally) globals.
229232
const MCSection *TargetLoweringObjectFile::
230-
SectionForGlobal(const GlobalValue *GV, Mangler *Mang,
233+
SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang,
231234
const TargetMachine &TM) const {
232-
assert(!GV->isDeclaration() && !GV->hasAvailableExternallyLinkage() &&
233-
"Can only be used for global definitions");
234-
235-
SectionKind Kind = SectionKindForGlobal(GV, TM);
236-
237235
// Select section name.
238236
if (GV->hasSection()) {
239237
// If the target has special section hacks for specifically named globals,
@@ -254,6 +252,7 @@ SectionForGlobal(const GlobalValue *GV, Mangler *Mang,
254252
return SelectSectionForGlobal(GV, Kind, Mang, TM);
255253
}
256254

255+
257256
// Lame default implementation. Calculate the section name for global.
258257
const MCSection *
259258
TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV,

0 commit comments

Comments
 (0)