[LLVMbugs] [Bug 8993] New: Constant string codegen broken by r123585

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jan 17 02:34:15 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=8993

           Summary: Constant string codegen broken by r123585
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: devlists at shadowlab.org
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=6016)
 --> (http://llvm.org/bugs/attachment.cgi?id=6016)
simple sample file

“123585 by rafael, 18:19
Only put unnamed_addr constants in mergeable sections. Fixes PR8297.
Modified /llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp”

After this commit, most C string end up in the data segment instead of text
segment, just like if the compiler was invoked with -fwritable-string.
This is a important issue as it break CFString and constant obj-c string
codegen with clang.

When trying to link any object compiled after this change, the linker emit this
warning for each object that contains constant CF/NSString.

ld: warning: -fwritable-strings not compatible with literal CF/NSString in
/WBAEFunctions.o

And here is a sample of the assembly generated before and after this change:

----------- before:
    .section    __TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
    .asciz     "Hello World"

----------- after:
    .section    __DATA,__data
L_.str:                                 ## @.str
    .asciz     "Hello World"


I attached a sample file used to generate this assembly and the result before
and after the change.
I simply use "clang -S" to compile this file.

Note: the default target is x86_64-apple-darwin10

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list