put normal data into .data instead of .data.rel on elf systems.
authorChris Lattner <sabre@nondot.org>
Sun, 26 Jul 2009 03:06:11 +0000 (03:06 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 26 Jul 2009 03:06:11 +0000 (03:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77116 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetAsmInfo.h
lib/Target/ELFTargetAsmInfo.cpp
test/CodeGen/X86/global-sections.ll

index e1ac6969aa5a9ae82b1c67e314b4d7ed8ea0aaff..d5273a385b9d0f878ae34e588864655850302f73 100644 (file)
@@ -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; }
index da8ed73852be2cab960fc8b1f6fb4e346b854668..880dfbc0a9365c1cf0c6cd5a6768980c670bbcee 100644 (file)
@@ -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;
index ef31defeb533d9b6b5c449861b2722f83f7f9a60..ddfb3523910638901d5a14f3438870c951427ce8 100644 (file)
 
 ; 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
+