Take the following source:
int g1(int);
int h(int *a, int *b)__attribute__((pure));
void link_error();

int g(void)
{
  int t = 0, t1 = 2;
  int t2 = h(&t, &t1);
  if (t != 0)
    link_error ();
  if (t1 != 2)
    link_error ();
  g1(t2);
  if (t != 0)
    link_error ();
  if (t1 != 2)
    link_error ();
  return t2 == 2;
}

We should not have link_error referenced at all. 
Even on the improved aliasing branch we get:
Variable: t, UID 1278, int, is addressable, call clobbered, default def: t_1

Variable: t1, UID 1279, int, is addressable, call clobbered, default def: t1_3


That is incorrect, as t and t1 are not call clobbered as pure functions cannot
cause something to escape.


-- 
           Summary: pure functions cause things to be call clobbered still
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: missed-optimization, alias
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


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

Reply via email to