public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/56139] New: unmodified static data could go in .rodata, not .data
@ 2013-01-29 10:06 amker.cheng at gmail dot com
  2015-01-23 10:40 ` [Bug tree-optimization/56139] " ramana at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: amker.cheng at gmail dot com @ 2013-01-29 10:06 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56139

             Bug #: 56139
           Summary: unmodified static data could go in .rodata, not .data
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: amker.cheng@gmail.com


For below program:

static int x[] = {1, 2, 3, 4};

void bar (int x);
int func(int i)
{
    int * const p = (int * const)&x;
    bar(p[i]);

    return 0;
}

build with:
arm-none-eabi-gcc -mthumb -mcpu=cortex-m0 -Os ...

The generated assembly code is:
    .text
    .align    1
    .global    func
    .code    16
    .thumb_func
    .type    func, %function
func:
    push    {r3, lr}
    ldr    r3, .L2
    lsl    r0, r0, #2
    ldr    r0, [r0, r3]
    bl    bar
    @ sp needed for prologue
    mov    r0, #0
    pop    {r3, pc}
.L3:
    .align    2
.L2:
    .word    .LANCHOR0
    .size    func, .-func
    .data
    .align    2
    .set    .LANCHOR0,. + 0
    .type    x, %object
    .size    x, 16
x:
    .word    1
    .word    2
    .word    3
    .word    4

while GCC 4.6 puts x in .rodata.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-07-27  9:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-29 10:06 [Bug tree-optimization/56139] New: unmodified static data could go in .rodata, not .data amker.cheng at gmail dot com
2015-01-23 10:40 ` [Bug tree-optimization/56139] " ramana at gcc dot gnu.org
2021-12-25  9:55 ` [Bug ipa/56139] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
2022-10-19  8:52 ` [Bug ipa/56139] [10/11/12/13 " rguenth at gcc dot gnu.org
2023-01-14 21:56 ` hubicka at gcc dot gnu.org
2023-04-26  6:55 ` [Bug ipa/56139] [10/11/12/13/14 " rguenth at gcc dot gnu.org
2023-07-27  9:19 ` [Bug ipa/56139] [11/12/13/14 " rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).