[llvm-commits] [llvm] r93844 - in /llvm/trunk: lib/Target/TargetLoweringObjectFile.cpp lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp test/CodeGen/X86/global-sections.ll
Chris Lattner
sabre at nondot.org
Mon Jan 18 19:06:02 PST 2010
Author: lattner
Date: Mon Jan 18 21:06:01 2010
New Revision: 93844
URL: http://llvm.org/viewvc/llvm-project?rev=93844&view=rev
Log:
fix a significant difference between llvm and gcc on ELF systems:
GCC would put weak zero initialized mutable data in the .bss section,
we would put it into a crasy '.gnu.linkonce.b.test,"aw", at nobits'
section. Fixing this will allow simplifications next up.
Modified:
llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
llvm/trunk/test/CodeGen/X86/global-sections.ll
Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=93844&r1=93843&r2=93844&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Mon Jan 18 21:06:01 2010
@@ -565,7 +565,6 @@
if (Kind.isThreadData()) return ".gnu.linkonce.td.";
if (Kind.isThreadBSS()) return ".gnu.linkonce.tb.";
- if (Kind.isBSS()) return ".gnu.linkonce.b.";
if (Kind.isDataNoRel()) return ".gnu.linkonce.d.";
if (Kind.isDataRelLocal()) return ".gnu.linkonce.d.rel.local.";
if (Kind.isDataRel()) return ".gnu.linkonce.d.rel.";
@@ -581,7 +580,7 @@
// If this global is linkonce/weak and the target handles this by emitting it
// into a 'uniqued' section name, create and return the section now.
- if (GV->isWeakForLinker() && !Kind.isCommon()) {
+ if (GV->isWeakForLinker() && !Kind.isCommon() && !Kind.isBSS()) {
const char *Prefix = getSectionPrefixForUniqueGlobal(Kind);
SmallString<128> Name;
Name.append(Prefix, Prefix+strlen(Prefix));
@@ -634,6 +633,9 @@
if (Kind.isThreadData()) return TLSDataSection;
if (Kind.isThreadBSS()) return TLSBSSSection;
+ // Note: we claim that common symbols are put in BSSSection, but they are
+ // really emitted with the magic .comm directive, which creates a symbol table
+ // entry but not a section.
if (Kind.isBSS() || Kind.isCommon()) return BSSSection;
if (Kind.isDataNoRel()) return DataSection;
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=93844&r1=93843&r2=93844&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Mon Jan 18 21:06:01 2010
@@ -718,7 +718,7 @@
// Don't put things that should go in the cstring section into "comm".
!TheSection->getKind().isMergeableCString() &&
!GVar->isThreadLocal() &&
- (GVar->hasLocalLinkage() || GVar->isWeakForLinker())) {
+ (GVar->hasLocalLinkage())) {
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
if (const char *LComm = MAI->getLCOMMDirective()) {
Modified: llvm/trunk/test/CodeGen/X86/global-sections.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-sections.ll?rev=93844&r1=93843&r2=93844&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/global-sections.ll (original)
+++ llvm/trunk/test/CodeGen/X86/global-sections.ll Mon Jan 18 21:06:01 2010
@@ -119,4 +119,19 @@
; LINUX:G9
+ at G10 = weak global [100 x i32] zeroinitializer, align 32 ; <[100 x i32]*> [#uses=0]
+
+
+; DARWIN: .section __DATA,__datacoal_nt,coalesced
+; DARWIN: .globl _G10
+; DARWIN: .weak_definition _G10
+; DARWIN: .align 5
+; DARWIN: _G10:
+; DARWIN: .space 400
+
+; LINUX: .bss
+; LINUX: .weak G10
+; LINUX: .align 32
+; LINUX: G10:
+; LINUX: .zero 400
More information about the llvm-commits
mailing list