[PATCH] A new HeapToStack allocation promotion pass

David Tweed david.tweed at arm.com
Tue Sep 24 07:04:07 PDT 2013


|This should work correctly because it is testing the variables in SSA form. Your example is really:

|int* p = malloc(<blah>);
|if (not_big_enough) {
|    q = realloc(p,<blah>);
|r = phi(p, q)

|and there is not a free of p on every path out of the function.

Thanks for clarifying that. That's the only case of a standard library function I can think of that is intended to be used to potentially "re-point" a pointer
that otherwise has a within-function scope. I can't immediately see how a function along the lines of

hidden_realloc_ptr(int** p,int n) { free(*p); *p=malloc(n); }

used in place of the realloc() call above as


would fare, but if that's handled without generating incorrect code then I think then the only snag I could think of isn't a problem.


More information about the llvm-commits mailing list