This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Come up with htab_hash_string_vptr and use string-specific if possible.
- From: Martin Liška <mliska at suse dot cz>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 2 Nov 2018 09:10:29 +0100
- Subject: Re: [PATCH] Come up with htab_hash_string_vptr and use string-specific if possible.
- References: <02950965-07c6-8008-a95b-413f9e0f53b7@suse.cz> <CAFiYyc0vAEXNHgadYNScHjcPBV4Ys2u0zhJGJMfE_sr-s+uPrw@mail.gmail.com>
On 11/2/18 9:02 AM, Richard Biener wrote:
> On Wed, Oct 31, 2018 at 5:40 PM Martin Liška <mliska@suse.cz> wrote:
>>
>> Hi.
>>
>> As seen in r265663 having htab_hash_string accepting const char * would
>> report a compilation error. The void * argument is needed for old C-style
>> htab used in libiberty. I'm suggesting to come up with htab_hash_string_vptr and
>> change signature of the old one (htab_hash_string). And putting these into
>> hashtab.h will make it inlinable in C++-style hash table.
>>
>> Patch survives regression tests on ppc64le-linux-gnu.
>> Total cc1 change with the patch:
>> +0.0% +2.09Ki
>>
>> Hope it's acceptable.
>
> What's the reason to inline the implementation?
Doing that can enable inlining of hash_table::* functions (find_slot_with_hash, ...)
in gcc.
I guess you want to
> get a compilation error when calling htab_hash_string on a non-string?
Yep.
> But then libiberty isn't C++ an is used in other projects which you
> may be breaking with your patch?
Ah, ok, that's new for me that it's used elsewhere :)
>
> A solution might be to poison htab_hash_string and provide our own
> variant.
Will work on that.
Martin
>
> Richard.
>
>> Thanks,
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2018-10-31 Martin Liska <mliska@suse.cz>
>>
>> * gengtype-state.c (read_state): Use newly added
>> htab_hash_string_vptr.
>> * gensupport.c (gen_mnemonic_attr): Likewise.
>> (check_define_attr_duplicates): Likewise.
>> * godump.c (go_finish): Likewise.
>>
>> include/ChangeLog:
>>
>> 2018-10-31 Martin Liska <mliska@suse.cz>
>>
>> * hashtab.h (htab_hash_string): Change signature
>> to const char * and make it static inline.
>> (htab_hash_string_vptr): Likewise.
>>
>> libcpp/ChangeLog:
>>
>> 2018-10-31 Martin Liska <mliska@suse.cz>
>>
>> * files.c (_cpp_init_files): Use htab_hash_string_vptr.
>>
>> libiberty/ChangeLog:
>>
>> 2018-10-31 Martin Liska <mliska@suse.cz>
>>
>> * hashtab.c:
>> (htab_hash_string): Move to header file.
>> ---
>> gcc/gengtype-state.c | 2 +-
>> gcc/gensupport.c | 4 ++--
>> gcc/godump.c | 6 +++---
>> include/hashtab.h | 47 ++++++++++++++++++++++++++++++++++++++++++--
>> libcpp/files.c | 2 +-
>> libiberty/hashtab.c | 38 -----------------------------------
>> 6 files changed, 52 insertions(+), 47 deletions(-)
>>
>>