On Wed, May 16, 2012 at 3:16 PM, Diego Novillo <dnovi...@google.com> wrote:
> 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.

Because it accepts any type as tree argument?  It's of course not less
type safety than using macros, but less type safety compared to not
using 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.

If they ain't templates they are not templates.  And thus do not need to
stay in the header.  Not sure what you are after here ;)

>>> 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.

That's of course not exactly the same.  The checking fns should be able
to unconditionally use const_tree anyway.

Richard.

>
> Diego.

Reply via email to