[llvm-dev] alloca combining, not (yet) possible ?

Caldarale, Charles R via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 31 05:30:39 PDT 2015


> From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Nat! via llvm-dev
> Subject: [llvm-dev] alloca combining, not (yet) possible ?

> I tried to get llvm (3.7) to optimize superflous allocas away, but 
> so far I haven't figured out how. Should I adorn something with 
> some attributes ?

Yes.
 
> void g( void)
> {
>	struct a_b   x;
>	struct a_b   y;
>
>	x.a = 1;
>	x.b = 2;
>	f( &x);
>
>	// x no longer needed
>	// expect y to reuse x space
>	y.a = 1;
>	y.b = 3;
>	f( &y);
> }

You have not provided us with the declaration for f().  Unless its argument is marked with the nocapture attribute, the compilation of g() cannot assume that f() has not retained a pointer to the x struct and is using it in the second call.

 - Chuck
 


More information about the llvm-dev mailing list