[LLVMbugs] [Bug 9520] New: 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 06:25:34 PDT 2011


           Summary: Optimizing a data var to a BSS one drops explicit
                    section attribute
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: Tim.Deegan at citrix.com
                CC: llvmbugs at cs.uiuc.edu

Hi. Apologies if I have the wrong component -- not sure where exactly this
optimization happens.

Compiling this code:

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

clang -O1 cunningly spots that "var" only ever holds one of two values and 
replaces it with a 1-byte flag in BSS that it uses to generate the right
value at run time.  That's great, except that I explicitly marked the variable
with the section I want it in, and now it's in BSS.  A more complex version of 
this trips up a compile-time check in Xen that init-only code has all its 
variables in init-only data/bss sections. 

Can this optimization be made to respect explicit section attributes?

I'm using: 

clang version 2.9 (trunk 125745)
Target: x86_64-unknown-linux-gnu
Thread model: posix



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