This is the mail archive of the
mailing list for the GCC project.
Re: Redundant / wasted stack space and instructions
- From: Jeff Law <law at redhat dot com>
- To: pshortis at dataworx dot com dot au, gcc at gcc dot gnu dot org
- Date: Mon, 14 Apr 2014 20:54:16 -0600
- Subject: Re: Redundant / wasted stack space and instructions
- Authentication-results: sourceware.org; auth=none
- References: <56725ae021420820a141e752c0c2b748 at dataworx dot com dot au>
On 04/14/14 18:58, firstname.lastname@example.org wrote:
The only way to know for sure is to dig through the debugging dumps to
understand why any given pseudo register was not assigned to a hard
I'm porting to a 16 bit micro and noticed that when optimization is
enabled (function.c:2101), most (non-volatile, non-addressed) stack
variables are copied into virtual registers. I assume this is so the
register allocator will attempt to allocate them to physical registers.
Unfortunately, in those cases where there are a lot of stack parameters
and those virtual registers are spilled to local variables a lot of code
and stack space is wasted copying an image of the stack parameters into
a spill slot instead of the overflow dropping back to use the original
stack parameter space.
For example ...
I'm aware that there are cases where the stack parameters are unsuitable
as spill locations (due to partial values, alignment etc) but the
majority of cases I see such as the example above the stack parameters
are viable spill locations. In the case illustrated above the required
stack space has blown out significantly and there are a host of
redundant load/store operations that could be eliminated if the spill
were to the stack parameters.
For small micros such as MSP430 & friends and many of the Renasis MCUs,
some of which only have 2K or ram on board, this could be a real issue.
Although I reproduced the same behaviour on i386 using a stock compiler,
I was wondering if there was something missing in my port that prevents
spilling to stack locations, or a cleanup pass that addresses this issue ?
If you're doing a new port, I would also recommend taking the time to
investigate and possibly tune it to utilize LRA. It's been our
experience that LRA, after tuning, produces superior code when compared
to the old reload pass.