aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Target/TargetAsmInfo.h4
-rw-r--r--lib/Target/TargetAsmInfo.cpp12
2 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/Target/TargetAsmInfo.h b/include/llvm/Target/TargetAsmInfo.h
index 7af2c03aa6..3f7dbc7206 100644
--- a/include/llvm/Target/TargetAsmInfo.h
+++ b/include/llvm/Target/TargetAsmInfo.h
@@ -471,6 +471,10 @@ namespace llvm {
SectionFlagsForGlobal(const GlobalValue *GV = NULL,
const char* name = NULL) const;
+ /// SectionForGlobal - This hooks returns proper section name for given
+ /// global with all necessary flags and marks.
+ const char* SectionForGlobal(const GlobalValue *GV) const;
+
// Accessors.
//
const char *getTextSection() const {
diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp
index 404e152da7..8e34fc30ec 100644
--- a/lib/Target/TargetAsmInfo.cpp
+++ b/lib/Target/TargetAsmInfo.cpp
@@ -254,3 +254,15 @@ TargetAsmInfo::SectionFlagsForGlobal(const GlobalValue *GV,
return flags;
}
+
+const char*
+TargetAsmInfo::SectionForGlobal(const GlobalValue *GV) const {
+ SectionKind::Kind kind = SectionKindForGlobal(GV);
+
+ if (kind == SectionKind::Text)
+ return getTextSection();
+ else if (kind == SectionKind::BSS && getBSSSection())
+ return getBSSSection();
+
+ return getDataSection();
+}