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
This commit is contained in:
Evan Cheng 2009-02-18 02:19:52 +00:00
parent ccd846b73f
commit caa0c2cadd
4 changed files with 12 additions and 3 deletions

View 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()) {

View 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()) {

View 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()) {

View File

@ -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