[LLVMbugs] [Bug 9520] Optimizing a data var to a BSS one drops explicit section attribute

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 21 11:25:11 PDT 2011


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

Chris Lattner <clattner at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clattner at apple.com
         Resolution|                            |INVALID

--- Comment #2 from Chris Lattner <clattner at apple.com> 2011-03-21 13:25:10 CDT ---
The actual problem here is that you're looking for some additional semantic
that is not visible to the compiler.  The fix for this is to mark the variable
as "attribute(used)" in addition to specifying a section.  For example:


void trial(int arg) {
    static int __attribute__ ((used, __section__ (".init.data"))) var = 42;
    if (arg)
        var = 0;
    printf("%i\n", var);
}

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