This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Using exception specifications to help compiler
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Wolfgang Bangerth <bangerth at ices dot utexas dot edu>
- Cc: nathan at codesourcery dot com, gcc at gcc dot gnu dot org
- Date: 04 Jun 2003 18:16:47 -0700
- Subject: Re: Using exception specifications to help compiler
- References: <Pine.LNX.4.44.0306041351140.21442-100000@gandalf.ices.utexas.edu>
On Wed, 2003-06-04 at 12:25, Wolfgang Bangerth wrote:
>
> Inspired by an article by Nathan Sidwell in the proceedings of the GCC
> summit, I experimented a little with adding throw() specifications to some
> 500 functions in our library. I estimate that this might cover about a
> third of all small or often called functions for which I would expect this
> to be significant.
>
> The results are the following: file sizes are slightly reduced on average,
> but run-time increases by about 1.5 per cent (details below).
The compiler can optimize successfully only if all functions called by
the "throw ()" function also have "throw ()" -- or can be inlined, and
do do not throw exceptions.
I suspect that in your case, you have something like:
void f();
void g() throw () { f(); }
In that case, the "throw ()" on "g" will actually make it bigger -- it
must now catch any exception thrown by "f" and call "unexpected". That
would possibly also account for the slowdown, if you got worse cache
performance.
The other possibility is that the additional "throw ()" specifications
are causing the compiler to do more inlining, which is causing worse
performance in your particular case.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com