diff options
author | Evan Cheng <evan.cheng@apple.com> | 2009-02-18 02:19:52 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2009-02-18 02:19:52 +0000 |
commit | caa0c2caddcfb56de09e016c4c153d0609ffcf6e (patch) | |
tree | 91bb25a13862692d2b2df61a4a6258551adb2dcf | |
parent | ccd846b73ffce9296e392e550712926845098fab (diff) |
GV with null value initializer shouldn't go to BSS if it's meant for a mergeable strings section. Currently it only checks for Darwin. Someone else please check if it should apply to other targets as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64877 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp | 4 | ||||
-rw-r--r-- | lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp | 3 | ||||
-rw-r--r-- | lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp | 4 | ||||
-rw-r--r-- | test/CodeGen/X86/cstring.ll | 4 |
4 files changed, 12 insertions, 3 deletions
diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index 83df20cc17..822cc2eb75 100644 --- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -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()) { diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index 5f3ba931fa..6c5d8b9d47 100644 --- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -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()) { diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index 75a34a6ec6..9af3ba62db 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -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 index 0000000000..27d6181db8 --- /dev/null +++ b/test/CodeGen/X86/cstring.ll @@ -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 |