optimize malloc to stack allocation.

Ondřej Bílka neleai@seznam.cz
Wed Jan 9 16:04:00 GMT 2013


Hello,

gcc currently does not even optimize following fragment:

int foo(){
  char *x=malloc(64);
  free(x);
}

It should be possible to change malloc with small size and there is free
that dominates that malloc into alloca. 

Also when size it is not known it could be (perhaps with profiling)
turned into conditional alloca.

-- 

static from nylon underwear



More information about the Gcc mailing list