This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: rfc: early sra breaks stdarg optimization


On Tue, Feb 13, 2007 at 11:45:12AM -0800, Richard Henderson wrote:
> On mainline we're now doing SRA before inlining.  This is all well
> and good.  Unfortunately, it can break the scanning that tree-stdarg.c
> does for structures.
> 
> This can be seen in failures of gcc.c-torture/execute/stdarg-4.c
> (at -O1) and gcc.c-torture/execute/stdarg-1.c (at -O3) on Alpha.
> 
> The scanning in tree-stdarg.c relies on seeing a store to
> ap.__offset in order to know that a read from the va_list has
> occurred.  If we run sra first, this store initially turns into
> a store to a scalar, and then later is eliminated by dce.
> 
> I fear that to fix this Properly would require a major rewrite
> to tree-stdarg.c; not something I'm looking forward to right now.

Without the va_list stores I guess it would be orders of magnitude
harder to detect how many arguments are needed.

> A hack that appears to work is to simply deny scalarizing va_list
> in the early passes.  We'll do it again after stdarg runs anyway,
> and that will produce results similar to what we get on previous
> branches.

Yeah, I think this is certainly he easiest way out of this for now.

> A hack that does not work (and I hoped would) is to run the stdarg
> optimization pass early as well, if va_list is an aggregate.  But
> we have no aliasing information then so, boom.

Guess the lack of alias info would be fixable in tree-stdarg.c, nevertheless
it is a bad idea to run the stdarg pass that early - we want several
optimizations to run on the function to kill dead code and simplify things,
because very early some stdarg arguments might be seen as needed and only
later on proved as unneeded.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]