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

           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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


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

Cheers,

Tim.

-- 
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to