public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amker.cheng at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/56139] New: unmodified static data could go in .rodata, not .data
Date: Tue, 29 Jan 2013 10:06:00 -0000	[thread overview]
Message-ID: <bug-56139-4@http.gcc.gnu.org/bugzilla/> (raw)


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.


             reply	other threads:[~2013-01-29 10:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-29 10:06 amker.cheng at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-56139-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).