[llvm-dev] alloca combining, not (yet) possible ?
Nat! via llvm-dev
llvm-dev at lists.llvm.org
Mon Aug 31 07:13:06 PDT 2015
Björn Steinbrink schrieb:
> // Lifetime of y starts here
> struct a_b y;
> y.a = 1;
> y.b = 3;
> // Lifetime of y ends here
Nice, thanks very much. This does the alloca combining (even without
having to specify "nocapture"). Wrapping my clang output with lifetime
calls shouldn't be a problem.
The code that does that optimization, is I assume:
I would like to take the alloca combining a step further still, which is
the combining of allocas across functions, at least on tail calls.
My current idea would be to
* invent an attribute to mark my parameter. Lets say "reusealloca"
* at the beginning of the optimization pass, collect all parameters of
type reusealloca and place them in the alloca map with lifetimes ending
before the tail call (figure out how to find it)
void h( struct a_b *p);
void g( struct a_b __attribute((reusealloca)) *x)
struct a_b y; // unneeded, use space provided by x
y.a = 18;
y.b = x->b; // unneeded, &y.b == &x->b
void f( void)
struct a_b x;
x.a = 1;
x.b = 3;
Does that sound feasible ?
More information about the llvm-dev