Take the following example from PR 21591:

struct a
{
  int length;
  int a1[256];
};

struct a *malloc1(__SIZE_TYPE__) __attribute__((malloc));
void free(void*);

void f(void)
{
   struct a *a = malloc1(sizeof(struct a));
   struct a *b = malloc1(sizeof(struct a));
   struct a *c = malloc1(sizeof(struct a));
   int i;
    for (i = 0; i < 256; i++) {
      b->a1[i] = i;
      c->a1[i] = i;
    }
    for (i = 0; i < 256; i++) {
      a->a1[i] = b->a1[i] + c->a1[i];
    }
    free(a);
    free(b);
    free(c);
}

----
In .alias1:
  i.0_18 = i_1;
  #   HEAP.7_46 = V_MAY_DEF <HEAP.7_22>;
  b_6->a1[i.0_18] = i_1;
  i.0_19 = i_1;
  #   HEAP.8_47 = V_MAY_DEF <HEAP.8_23>;
  c_8->a1[i.0_19] = i_1;
  i_20 = i_1 + 1;

In .alias2:
  #   HEAP.19_14 = V_MAY_DEF <HEAP.19_21>;
  b_5->a1[i_65] = i_65;
  #   HEAP.20_73 = V_MAY_DEF <HEAP.20_10>;
  c_7->a1[i_65] = i_65;
  i_20 = i_65 + 1;

---
I don't know how much harm in compile time does this hurt in normal code but we 
then keep on adding 
them to clobbered variables:
  #   HEAP.6_27 = V_MAY_DEF <HEAP.6_24>;
  #   HEAP.7_28 = V_MAY_DEF <HEAP.7_25>;
  #   HEAP.8_29 = V_MAY_DEF <HEAP.8_26>;
  #   HEAP.18_6 = V_MAY_DEF <HEAP.18_9>;
  #   HEAP.19_8 = V_MAY_DEF <HEAP.19_64>;
  #   HEAP.20_1 = V_MAY_DEF <HEAP.20_4>;
  a_3 = malloc1 (1028);

-- 
           Summary: [4.1 Regression] tree-ssa-alias creates a new virtual
                    variable for malloc each time may_alias is run (HEAP)
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: memory-hog, compile-time-hog
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org
                CC: dberlin at gcc dot gnu dot org,dnovillo at gcc dot gnu
                    dot org,gcc-bugs at gcc dot gnu dot org


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

Reply via email to