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

* [Bug tree-optimization/56139] unmodified static data could go in .rodata, not .data
  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 ` 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
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ramana at gcc dot gnu.org @ 2015-01-23 10:40 UTC (permalink / raw)
  To: gcc-bugs

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

Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-01-23
                 CC|                            |ramana at gcc dot gnu.org
     Ever confirmed|0                           |1
      Known to fail|                            |4.9.0, 5.0

--- Comment #1 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> ---
If it worked in 4.6 then this is a regression, no ? don't have a 4.6 tree handy
to check it but ...


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

* [Bug ipa/56139] [9/10/11/12 Regression] unmodified static data could go in .rodata, not .data
  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 ` pinskia at gcc dot gnu.org
  2022-10-19  8:52 ` [Bug ipa/56139] [10/11/12/13 " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-25  9:55 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |ipa
   Target Milestone|---                         |13.0
           Keywords|                            |deferred
      Known to fail|                            |4.7.1
           Severity|enhancement                 |normal
                 CC|                            |marxin at gcc dot gnu.org
            Summary|unmodified static data      |[9/10/11/12 Regression]
                   |could go in .rodata, not    |unmodified static data
                   |.data                       |could go in .rodata, not
                   |                            |.data

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
We do handle:
static int x[] = {1, 2, 3, 4};

void bar (int x);

int func(int i)
{
    bar(x[i]);

    return 0;
}

Just fine. It is the IR of the other case where we mess up. And it looks like
it is a regression too. I suspect it is because we used to be able to create
back the ARARY_REF in GCC 4.6.x and that was removed in GCC 4.7 as it caused
other issues.

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

* [Bug ipa/56139] [10/11/12/13 Regression] unmodified static data could go in .rodata, not .data
  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 ` rguenth at gcc dot gnu.org
  2023-01-14 21:56 ` hubicka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-19  8:52 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|deferred                    |
           Priority|P3                          |P2

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The main reason IPA doesn't get this is that we end up with

int func (int i)
{
  long unsigned int _1;
  long unsigned int _2;
  int * _3;
  int _4;

  <bb 2> [local count: 1073741824]:
  _1 = (long unsigned int) i_5(D);
  _2 = _1 * 4;
  _3 = &x + _2;
  _4 = *_3;
  bar (_4);
  return 0;
}

thus an IPA_ADDR ref of 'x' and 'x' TREE_ADDRESSABLE.  We do not try to
handle address-taken statics in full generality though eventually
modref-like analysis might be able to compute that the address of the
static variable doesn't escape from 'func' and that 'func' doesn't write
to 'x'?

Not re-creating x[i] is a correctness issue, that cannot be recovered.
One could abuse TARGET_MEM_REF to avoid the address-taking though, but
that would be abuse and likely pessimization as TMR isn't handled in
full generality in a lot of passes.

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

* [Bug ipa/56139] [10/11/12/13 Regression] unmodified static data could go in .rodata, not .data
  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
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: hubicka at gcc dot gnu.org @ 2023-01-14 21:56 UTC (permalink / raw)
  To: gcc-bugs

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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #4 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
I have some code that makes it possible to attach summaries to references (like
we do for calls and symbols) and then mark addresses that are never used for
compoarsion.  Similarly we could probably mark readonly addresses.
We could even squeeze out a bit in the reference representation itself.
Is there easy way to tell if address is never read from during IPA summary
generation time?

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

* [Bug ipa/56139] [10/11/12/13/14 Regression] unmodified static data could go in .rodata, not .data
  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
                   ` (3 preceding siblings ...)
  2023-01-14 21:56 ` hubicka at gcc dot gnu.org
@ 2023-04-26  6:55 ` rguenth at gcc dot gnu.org
  2023-07-27  9:19 ` [Bug ipa/56139] [11/12/13/14 " rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-26  6:55 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.0                        |13.2

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 13.1 is being released, retargeting bugs to GCC 13.2.

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

* [Bug ipa/56139] [11/12/13/14 Regression] unmodified static data could go in .rodata, not .data
  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
                   ` (4 preceding siblings ...)
  2023-04-26  6:55 ` [Bug ipa/56139] [10/11/12/13/14 " rguenth at gcc dot gnu.org
@ 2023-07-27  9:19 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-27  9:19 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.2                        |11.5

^ 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).