[Bug ipa/56139] [10/11/12/13 Regression] unmodified static data could go in .rodata, not .data

2022-10-19 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56139

Richard Biener  changed:

   What|Removed |Added

   Keywords|deferred|
   Priority|P3  |P2

--- Comment #3 from Richard Biener  ---
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;

   [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.

[Bug ipa/56139] [10/11/12/13 Regression] unmodified static data could go in .rodata, not .data

2023-01-14 Thread hubicka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56139

Jan Hubicka  changed:

   What|Removed |Added

 CC||hubicka at gcc dot gnu.org

--- Comment #4 from Jan Hubicka  ---
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?