Subject: Re: bug#15880: Compute C declarations for DEFSYMs automatically.

From: Paul Eggert <[email-masked]>
Date: Wed, 13 Nov 2013 21:26:46 -0800

Stefan Monnier wrote:
> without link-time optimization, it probably won't be any better than
> what we have

Actually, I would expect the reverse.
Suppose we run this:

   Lisp_Object x = !NILP (a) ? a : make_number (0);
   foo ();
   Lisp_Object y = !NILP (a) ? a : make_number (0);

With the implementation I suggested, any
decent compiler can do common subexpression elimination
and optimize away the calculation of y, even if foo is an external
function that does goodness knows what.  That optimization can't
be done with the current Emacs implementation, because the compiler
can't assume that Qnil remains unmodified across foo's call
(at least, not unless we have link time optimization
and can look inside foo's body).

If foo is a function pointer, even link time
optimization won't suffice for common subexpression
elimination, so the implementation I
suggested should be a win even if LTO is used,
even if the win isn't as large as it is in the
non-LTO case.