aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Target/TargetAsmInfo.h2
-rw-r--r--lib/Target/ELFTargetAsmInfo.cpp32
-rw-r--r--test/CodeGen/X86/global-sections.ll17
3 files changed, 28 insertions, 23 deletions
diff --git a/include/llvm/Target/TargetAsmInfo.h b/include/llvm/Target/TargetAsmInfo.h
index e1ac696..d5273a3 100644
--- a/include/llvm/Target/TargetAsmInfo.h
+++ b/include/llvm/Target/TargetAsmInfo.h
@@ -55,7 +55,7 @@ namespace llvm {
/// Thread local data.
ThreadData, ///< Initialized TLS data objects
ThreadBSS ///< Uninitialized TLS data objects
- } K; // This is private.
+ } K : 8; // This is private.
// FIXME: Eliminate.
Kind getKind() const { return K; }
diff --git a/lib/Target/ELFTargetAsmInfo.cpp b/lib/Target/ELFTargetAsmInfo.cpp
index da8ed73..880dfbc 100644
--- a/lib/Target/ELFTargetAsmInfo.cpp
+++ b/lib/Target/ELFTargetAsmInfo.cpp
@@ -49,34 +49,24 @@ ELFTargetAsmInfo::ELFTargetAsmInfo(const TargetMachine &TM)
const Section*
ELFTargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV,
SectionKind Kind) const {
- if (isa<Function>(GV))
- return TextSection;
-
- const GlobalVariable *GVar = cast<GlobalVariable>(GV);
switch (Kind.getKind()) {
- default: llvm_unreachable("Unsuported section kind for global");
- case SectionKind::BSS:
- return getBSSSection_();
- case SectionKind::Data:
- case SectionKind::DataRel:
- return DataRelSection;
- case SectionKind::DataRelLocal:
- return DataRelLocalSection;
- case SectionKind::DataRelRO:
- return DataRelROSection;
- case SectionKind::DataRelROLocal:
- return DataRelROLocalSection;
- case SectionKind::ROData:
- return getReadOnlySection();
+ default: llvm_unreachable("Unknown section kind");
+ case SectionKind::Text: return TextSection;
+ case SectionKind::BSS: return getBSSSection_();
+ case SectionKind::Data: return DataSection;
+ case SectionKind::DataRel: return DataRelSection;
+ case SectionKind::DataRelLocal: return DataRelLocalSection;
+ case SectionKind::DataRelRO: return DataRelROSection;
+ case SectionKind::DataRelROLocal: return DataRelROLocalSection;
+ case SectionKind::ROData: return getReadOnlySection();
case SectionKind::RODataMergeStr:
- return MergeableStringSection(GVar);
+ return MergeableStringSection(cast<GlobalVariable>(GV));
case SectionKind::RODataMergeConst: {
- const Type *Ty = GVar->getInitializer()->getType();
+ const Type *Ty = cast<GlobalVariable>(GV)->getInitializer()->getType();
const TargetData *TD = TM.getTargetData();
return getSectionForMergableConstant(TD->getTypeAllocSize(Ty), 0);
}
case SectionKind::ThreadData:
- // ELF targets usually support TLS stuff
return TLSDataSection;
case SectionKind::ThreadBSS:
return TLSBSSSection;
diff --git a/test/CodeGen/X86/global-sections.ll b/test/CodeGen/X86/global-sections.ll
index ef31def..ddfb352 100644
--- a/test/CodeGen/X86/global-sections.ll
+++ b/test/CodeGen/X86/global-sections.ll
@@ -39,4 +39,19 @@
; DARWIN: .const
; DARWIN: _G4:
-; .long 34
+; DARWIN: .long 34
+
+
+; int G5 = 47;
+@G5 = global i32 47
+
+; LINUX: .data
+; LINUX: .globl G5
+; LINUX: G5:
+; LINUX: .long 47
+
+; DARWIN: .data
+; DARWIN: .globl _G5
+; DARWIN: _G5:
+; DARWIN: .long 47
+