GV with null value initializer shouldn't go to BSS if it's meant for a mergeable...
authorEvan Cheng <evan.cheng@apple.com>
Wed, 18 Feb 2009 02:19:52 +0000 (02:19 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 18 Feb 2009 02:19:52 +0000 (02:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64877 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
test/CodeGen/X86/cstring.ll [new file with mode: 0644]

index 83df20cc170bacb78a6b4a5f4d7158697bccad20..822cc2eb75b3c6a5590d62b4e041afdcad0e2d68 100644 (file)
@@ -835,7 +835,9 @@ void ARMAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
   if (Subtarget->isTargetELF())
     O << "\t.type " << name << ",%object\n";
 
-  if (C->isNullValue() && !GVar->hasSection() && !GVar->isThreadLocal()) {
+  if (C->isNullValue() && !GVar->hasSection() && !GVar->isThreadLocal() &&
+      !(isDarwin &&
+        TAI->SectionKindForGlobal(GVar) == SectionKind::RODataMergeStr)) {
     // FIXME: This seems to be pretty darwin-specific
 
     if (GVar->hasExternalLinkage()) {
index 5f3ba931faf4e0fec265ace59315a5e81d72da5c..6c5d8b9d476756f94709c488fdf348d5baef839a 100644 (file)
@@ -915,7 +915,8 @@ void PPCDarwinAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
   if (C->isNullValue() && /* FIXME: Verify correct */
       !GVar->hasSection() &&
       (GVar->hasLocalLinkage() || GVar->hasExternalLinkage() ||
-       GVar->mayBeOverridden())) {
+       GVar->mayBeOverridden()) &&
+      TAI->SectionKindForGlobal(GVar) != SectionKind::RODataMergeStr) {
     if (Size == 0) Size = 1;   // .comm Foo, 0 is undefined, avoid it.
 
     if (GVar->hasExternalLinkage()) {
index 75a34a6ec642abd2e9debd6f83e77402472b8848..9af3ba62db042df6bf37043ed70e4a684d018abc 100644 (file)
@@ -799,7 +799,9 @@ void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
 
   SwitchToSection(TAI->SectionForGlobal(GVar));
 
-  if (C->isNullValue() && !GVar->hasSection()) {
+  if (C->isNullValue() && !GVar->hasSection() &&
+      !(Subtarget->isTargetDarwin() &&
+        TAI->SectionKindForGlobal(GVar) == SectionKind::RODataMergeStr)) {
     // FIXME: This seems to be pretty darwin-specific
     if (GVar->hasExternalLinkage()) {
       if (const char *Directive = TAI->getZeroFillDirective()) {
diff --git a/test/CodeGen/X86/cstring.ll b/test/CodeGen/X86/cstring.ll
new file mode 100644 (file)
index 0000000..27d6181
--- /dev/null
@@ -0,0 +1,4 @@
+; RUN: llvm-as < %s | llc -mtriple=i386-apple-darwin | not grep comm
+; rdar://6479858
+
+@str1 = internal constant [1 x i8] zeroinitializer