On 12-05-16 09:00 , Richard Guenther wrote:
On Wed, May 16, 2012 at 2:43 PM, Diego Novillo<dnovi...@google.com>  wrote:
On 12-05-16 05:41 , Richard Guenther wrote:

What's the reason for templating these functions?  They all take trees as
parameter!?


True.  I don't recall what Lawrence had in mind, but I remember that by
using templates here, you don't need to deal with the mess of distinguishing
tree from const_tree, and having to force constness out with ugly casts.

Well, but you get no typesafety for it in return.  You can simply provide
a const_tree overload.

There's less typing if you use the template variant. Not sure why you say there is less type safety with templates.

With using templates you are also forced to retain
these functions in the header file - another thing that I suppose you guys
were about to "fix"?  It's after all debugging code.

No, templated functions must always stay in the header file. There is no changing that.


Additionally, templates are producing slightly smaller code than the
non-template variant (about 0.2% smaller).  I'm not actually sure why this
happens, but it's consistent across all binaries.

Well, what did you compare?  Make sure to not have -fkeep-inline-functions,
otherwise you get all bodies as compared to only the instantiated bodies.

Two bootstrapped compilers built exactly the same, except one was using the template version, the other using the straight inline functions with const_tree parameters and CONST_CAST_TREE in return values.


Diego.

Reply via email to