* [PATCH] Fix up tm_clone_hasher
@ 2015-04-22 15:24 Marek Polacek
2015-04-30 9:40 ` Marek Polacek
0 siblings, 1 reply; 3+ messages in thread
From: Marek Polacek @ 2015-04-22 15:24 UTC (permalink / raw)
To: GCC Patches
handle_cache_entry in tm_clone_hasher looks wrong: the condition
if (e != HTAB_EMPTY_ENTRY || e != HTAB_DELETED_ENTRY) is always true. While
it could be fixed by just changing || into &&, I decided to follow suit and
do what we do in handle_cache_entry's elsewhere in the codebase. I've fixed
a formatting issue below while at it.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
I think this should also go into 5.1.
2015-04-22 Marek Polacek <polacek@redhat.com>
* varasm.c (handle_cache_entry): Fix logic.
diff --git gcc/varasm.c gcc/varasm.c
index 1597de1..3fc0316 100644
--- gcc/varasm.c
+++ gcc/varasm.c
@@ -5779,21 +5779,20 @@ struct tm_clone_hasher : ggc_cache_hasher<tree_map *>
static hashval_t hash (tree_map *m) { return tree_map_hash (m); }
static bool equal (tree_map *a, tree_map *b) { return tree_map_eq (a, b); }
- static void handle_cache_entry (tree_map *&e)
+ static void
+ handle_cache_entry (tree_map *&e)
{
- if (e != HTAB_EMPTY_ENTRY || e != HTAB_DELETED_ENTRY)
- {
- extern void gt_ggc_mx (tree_map *&);
- if (ggc_marked_p (e->base.from))
- gt_ggc_mx (e);
- else
- e = static_cast<tree_map *> (HTAB_DELETED_ENTRY);
- }
+ extern void gt_ggc_mx (tree_map *&);
+ if (e == HTAB_EMPTY_ENTRY || e == HTAB_DELETED_ENTRY)
+ return;
+ else if (ggc_marked_p (e->base.from))
+ gt_ggc_mx (e);
+ else
+ e = static_cast<tree_map *> (HTAB_DELETED_ENTRY);
}
};
-static GTY((cache))
- hash_table<tm_clone_hasher> *tm_clone_hash;
+static GTY((cache)) hash_table<tm_clone_hasher> *tm_clone_hash;
void
record_tm_clone_pair (tree o, tree n)
Marek
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix up tm_clone_hasher
2015-04-22 15:24 [PATCH] Fix up tm_clone_hasher Marek Polacek
@ 2015-04-30 9:40 ` Marek Polacek
2015-04-30 17:21 ` Jeff Law
0 siblings, 1 reply; 3+ messages in thread
From: Marek Polacek @ 2015-04-30 9:40 UTC (permalink / raw)
To: GCC Patches
Ping.
On Wed, Apr 22, 2015 at 05:24:43PM +0200, Marek Polacek wrote:
> handle_cache_entry in tm_clone_hasher looks wrong: the condition
> if (e != HTAB_EMPTY_ENTRY || e != HTAB_DELETED_ENTRY) is always true. While
> it could be fixed by just changing || into &&, I decided to follow suit and
> do what we do in handle_cache_entry's elsewhere in the codebase. I've fixed
> a formatting issue below while at it.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
> I think this should also go into 5.1.
>
> 2015-04-22 Marek Polacek <polacek@redhat.com>
>
> * varasm.c (handle_cache_entry): Fix logic.
>
> diff --git gcc/varasm.c gcc/varasm.c
> index 1597de1..3fc0316 100644
> --- gcc/varasm.c
> +++ gcc/varasm.c
> @@ -5779,21 +5779,20 @@ struct tm_clone_hasher : ggc_cache_hasher<tree_map *>
> static hashval_t hash (tree_map *m) { return tree_map_hash (m); }
> static bool equal (tree_map *a, tree_map *b) { return tree_map_eq (a, b); }
>
> - static void handle_cache_entry (tree_map *&e)
> + static void
> + handle_cache_entry (tree_map *&e)
> {
> - if (e != HTAB_EMPTY_ENTRY || e != HTAB_DELETED_ENTRY)
> - {
> - extern void gt_ggc_mx (tree_map *&);
> - if (ggc_marked_p (e->base.from))
> - gt_ggc_mx (e);
> - else
> - e = static_cast<tree_map *> (HTAB_DELETED_ENTRY);
> - }
> + extern void gt_ggc_mx (tree_map *&);
> + if (e == HTAB_EMPTY_ENTRY || e == HTAB_DELETED_ENTRY)
> + return;
> + else if (ggc_marked_p (e->base.from))
> + gt_ggc_mx (e);
> + else
> + e = static_cast<tree_map *> (HTAB_DELETED_ENTRY);
> }
> };
>
> -static GTY((cache))
> - hash_table<tm_clone_hasher> *tm_clone_hash;
> +static GTY((cache)) hash_table<tm_clone_hasher> *tm_clone_hash;
>
> void
> record_tm_clone_pair (tree o, tree n)
>
> Marek
Marek
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix up tm_clone_hasher
2015-04-30 9:40 ` Marek Polacek
@ 2015-04-30 17:21 ` Jeff Law
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Law @ 2015-04-30 17:21 UTC (permalink / raw)
To: Marek Polacek, GCC Patches
On 04/30/2015 03:30 AM, Marek Polacek wrote:
> Ping.
>
> On Wed, Apr 22, 2015 at 05:24:43PM +0200, Marek Polacek wrote:
>> handle_cache_entry in tm_clone_hasher looks wrong: the condition
>> if (e != HTAB_EMPTY_ENTRY || e != HTAB_DELETED_ENTRY) is always true. While
>> it could be fixed by just changing || into &&, I decided to follow suit and
>> do what we do in handle_cache_entry's elsewhere in the codebase. I've fixed
>> a formatting issue below while at it.
>>
>> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>> I think this should also go into 5.1.
>>
>> 2015-04-22 Marek Polacek <polacek@redhat.com>
>>
>> * varasm.c (handle_cache_entry): Fix logic.
OK. Though I do wonder if we should try to unify this with the other
instances to avoid the useless duplication.
jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-04-30 16:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-22 15:24 [PATCH] Fix up tm_clone_hasher Marek Polacek
2015-04-30 9:40 ` Marek Polacek
2015-04-30 17:21 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).