This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix handling of DEBUG_EXPR_DECLs/DEBUG_EXPRs in var-tracking (PR debug/43160)


On Thu, Feb 25, 2010 at 10:59 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> Without this patch we wouldn't notice that e.g. for:
> ?(value/s/u:SI 15:15 @0x1723030/0x1717290)
> ? ?offset 0
> ? ? ?(reg:SI 5 di [ iD.1615 ])
> ?name: iD.1615
> ? ?offset 0
> ? ? ?(value/s/u:SI 15:15 @0x1723030/0x1717290)
> ?(value/s/u:SI 1:1 @0x1722ee0/0x1717110)
> ? ?offset 0
> ? ? ?(value/s/u:SI 15:15 @0x1723030/0x1717290)
> ?(value/s/u:DI 2:4052 @0x1722ef8/0x1722bd0)
> ? ?offset 0
> ? ? ?(sign_extend:DI (plus:SI (value/s/u:SI 1:1 @0x1722ee0/0x1717110)
> ? ? ? ?(const_int 1 [0x1])))
> ?name: D#2
> ? ?offset 0
> ? ? ?(value/s/u:DI 2:4052 @0x1722ef8/0x1722bd0)
> ?(value/s/u:DI 3:4212 @0x1722f10/0x1722cf0)
> ? ?offset 0
> ? ? ?(plus:DI (debug_expr:DI D#2)
> ? ?(const_int -1 [0xffffffffffffffff]))
> ?name: D#1
> ? ?offset 0
> ? ? ?(value/s/u:DI 3:4212 @0x1722f10/0x1722cf0)
> ?(value/s/u:DI 4:276 @0x1722f28/0x17171a0)
> ? ?offset 0
> ? ? ?(debug_expr:DI D#1)
> ?name: D.2721
> ? ?offset 0
> ? ? ?(value/s/u:DI 4:276 @0x1722f28/0x17171a0)
> when di is reset, not only iD.1615 changed, but also D.2721. ?We were
> considering only VALUEs in links, but in reality DEBUG_EXPRs with their
> DEBUG_EXPR_DECLs are such links too. ?I'm not 100% sure whether all
> DEBUG_EXPR_DECLs necessarily are onepart vars, I assume they are and
> testing haven't revealed anything else.

Yes, I think they are (they were all SSA names originally).

> Bootstrapped/regtested on x86_64-linux and i686-linux. ?Ok for trunk?

Ok.  Do you have a testcase?

Thanks,
Richard.

> 2010-02-25 ?Jakub Jelinek ?<jakub@redhat.com>
>
> ? ? ? ?PR debug/43160
> ? ? ? ?* var-tracking.c (dv_onepart_p): Return true for DEBUG_EXPR_DECLs.
> ? ? ? ?(add_value_chain, add_value_chains, remove_value_chain,
> ? ? ? ?remove_value_chains): Handle DEBUG_EXPRs.
> ? ? ? ?(check_changed_vars_1, check_changed_vars_2): Handle DEBUG_EXPR_DECLs.
>
> --- gcc/var-tracking.c.jj ? ? ? 2010-02-23 15:09:44.000000000 +0100
> +++ gcc/var-tracking.c ?2010-02-25 15:03:16.000000000 +0100
> @@ -784,6 +785,9 @@ dv_onepart_p (decl_or_value dv)
> ? if (!decl)
> ? ? return true;
>
> + ?if (TREE_CODE (decl) == DEBUG_EXPR_DECL)
> + ? ?return true;
> +
> ? return (target_for_debug_bind (decl) != NULL_TREE);
> ?}
>
> @@ -2563,39 +2578,48 @@ loc_cmp (rtx x, rtx y)
> ?static int
> ?add_value_chain (rtx *loc, void *dvp)
> ?{
> - ?if (GET_CODE (*loc) == VALUE && (void *) *loc != dvp)
> + ?decl_or_value dv, ldv;
> + ?value_chain vc, nvc;
> + ?void **slot;
> +
> + ?if (GET_CODE (*loc) == VALUE)
> + ? ?ldv = dv_from_value (*loc);
> + ?else if (GET_CODE (*loc) == DEBUG_EXPR)
> + ? ?ldv = dv_from_decl (DEBUG_EXPR_TREE_DECL (*loc));
> + ?else
> + ? ?return 0;
> +
> + ?if (dv_as_opaque (ldv) == dvp)
> + ? ?return 0;
> +
> + ?dv = (decl_or_value) dvp;
> + ?slot = htab_find_slot_with_hash (value_chains, ldv, dv_htab_hash (ldv),
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?INSERT);
> + ?if (!*slot)
> ? ? {
> - ? ? ?decl_or_value dv = (decl_or_value) dvp;
> - ? ? ?decl_or_value ldv = dv_from_value (*loc);
> - ? ? ?value_chain vc, nvc;
> - ? ? ?void **slot = htab_find_slot_with_hash (value_chains, ldv,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? dv_htab_hash (ldv), INSERT);
> - ? ? ?if (!*slot)
> - ? ? ? {
> - ? ? ? ? vc = (value_chain) pool_alloc (value_chain_pool);
> - ? ? ? ? vc->dv = ldv;
> - ? ? ? ? vc->next = NULL;
> - ? ? ? ? vc->refcount = 0;
> - ? ? ? ? *slot = (void *) vc;
> - ? ? ? }
> - ? ? ?else
> + ? ? ?vc = (value_chain) pool_alloc (value_chain_pool);
> + ? ? ?vc->dv = ldv;
> + ? ? ?vc->next = NULL;
> + ? ? ?vc->refcount = 0;
> + ? ? ?*slot = (void *) vc;
> + ? ?}
> + ?else
> + ? ?{
> + ? ? ?for (vc = ((value_chain) *slot)->next; vc; vc = vc->next)
> + ? ? ? if (dv_as_opaque (vc->dv) == dv_as_opaque (dv))
> + ? ? ? ? break;
> + ? ? ?if (vc)
> ? ? ? ?{
> - ? ? ? ? for (vc = ((value_chain) *slot)->next; vc; vc = vc->next)
> - ? ? ? ? ? if (dv_as_opaque (vc->dv) == dv_as_opaque (dv))
> - ? ? ? ? ? ? break;
> - ? ? ? ? if (vc)
> - ? ? ? ? ? {
> - ? ? ? ? ? ? vc->refcount++;
> - ? ? ? ? ? ? return 0;
> - ? ? ? ? ? }
> + ? ? ? ? vc->refcount++;
> + ? ? ? ? return 0;
> ? ? ? ?}
> - ? ? ?vc = (value_chain) *slot;
> - ? ? ?nvc = (value_chain) pool_alloc (value_chain_pool);
> - ? ? ?nvc->dv = dv;
> - ? ? ?nvc->next = vc->next;
> - ? ? ?nvc->refcount = 1;
> - ? ? ?vc->next = nvc;
> ? ? }
> + ?vc = (value_chain) *slot;
> + ?nvc = (value_chain) pool_alloc (value_chain_pool);
> + ?nvc->dv = dv;
> + ?nvc->next = vc->next;
> + ?nvc->refcount = 1;
> + ?vc->next = nvc;
> ? return 0;
> ?}
>
> @@ -2605,7 +2629,7 @@ add_value_chain (rtx *loc, void *dvp)
> ?static void
> ?add_value_chains (decl_or_value dv, rtx loc)
> ?{
> - ?if (GET_CODE (loc) == VALUE)
> + ?if (GET_CODE (loc) == VALUE || GET_CODE (loc) == DEBUG_EXPR)
> ? ? {
> ? ? ? add_value_chain (&loc, dv_as_opaque (dv));
> ? ? ? return;
> @@ -2635,33 +2659,41 @@ add_cselib_value_chains (decl_or_value d
> ?static int
> ?remove_value_chain (rtx *loc, void *dvp)
> ?{
> - ?if (GET_CODE (*loc) == VALUE && (void *) *loc != dvp)
> - ? ?{
> - ? ? ?decl_or_value dv = (decl_or_value) dvp;
> - ? ? ?decl_or_value ldv = dv_from_value (*loc);
> - ? ? ?value_chain vc, dvc = NULL;
> - ? ? ?void **slot = htab_find_slot_with_hash (value_chains, ldv,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? dv_htab_hash (ldv), NO_INSERT);
> - ? ? ?for (vc = (value_chain) *slot; vc->next; vc = vc->next)
> - ? ? ? if (dv_as_opaque (vc->next->dv) == dv_as_opaque (dv))
> + ?decl_or_value dv, ldv;
> + ?value_chain vc;
> + ?void **slot;
> +
> + ?if (GET_CODE (*loc) == VALUE)
> + ? ?ldv = dv_from_value (*loc);
> + ?else if (GET_CODE (*loc) == DEBUG_EXPR)
> + ? ?ldv = dv_from_decl (DEBUG_EXPR_TREE_DECL (*loc));
> + ?else
> + ? ?return 0;
> +
> + ?if (dv_as_opaque (ldv) == dvp)
> + ? ?return 0;
> +
> + ?dv = (decl_or_value) dvp;
> + ?slot = htab_find_slot_with_hash (value_chains, ldv, dv_htab_hash (ldv),
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?NO_INSERT);
> + ?for (vc = (value_chain) *slot; vc->next; vc = vc->next)
> + ? ?if (dv_as_opaque (vc->next->dv) == dv_as_opaque (dv))
> + ? ? ?{
> + ? ? ? value_chain dvc = vc->next;
> + ? ? ? gcc_assert (dvc->refcount > 0);
> + ? ? ? if (--dvc->refcount == 0)
> ? ? ? ? ?{
> - ? ? ? ? ? dvc = vc->next;
> - ? ? ? ? ? gcc_assert (dvc->refcount > 0);
> - ? ? ? ? ? if (--dvc->refcount == 0)
> + ? ? ? ? ? vc->next = dvc->next;
> + ? ? ? ? ? pool_free (value_chain_pool, dvc);
> + ? ? ? ? ? if (vc->next == NULL && vc == (value_chain) *slot)
> ? ? ? ? ? ? ?{
> - ? ? ? ? ? ? ? vc->next = dvc->next;
> - ? ? ? ? ? ? ? pool_free (value_chain_pool, dvc);
> - ? ? ? ? ? ? ? if (vc->next == NULL && vc == (value_chain) *slot)
> - ? ? ? ? ? ? ? ? {
> - ? ? ? ? ? ? ? ? ? pool_free (value_chain_pool, vc);
> - ? ? ? ? ? ? ? ? ? htab_clear_slot (value_chains, slot);
> - ? ? ? ? ? ? ? ? }
> + ? ? ? ? ? ? ? pool_free (value_chain_pool, vc);
> + ? ? ? ? ? ? ? htab_clear_slot (value_chains, slot);
> ? ? ? ? ? ? ?}
> - ? ? ? ? ? return 0;
> ? ? ? ? ?}
> - ? ? ?gcc_unreachable ();
> - ? ?}
> - ?return 0;
> + ? ? ? return 0;
> + ? ? ?}
> + ?gcc_unreachable ();
> ?}
>
> ?/* If decl or value DVP refers to VALUEs from within LOC, remove backlinks
> @@ -2670,7 +2702,7 @@ remove_value_chain (rtx *loc, void *dvp)
> ?static void
> ?remove_value_chains (decl_or_value dv, rtx loc)
> ?{
> - ?if (GET_CODE (loc) == VALUE)
> + ?if (GET_CODE (loc) == VALUE || GET_CODE (loc) == DEBUG_EXPR)
> ? ? {
> ? ? ? remove_value_chain (&loc, dv_as_opaque (dv));
> ? ? ? return;
> @@ -6673,7 +6707,8 @@ check_changed_vars_1 (void **slot, void
> ? variable var = (variable) *slot;
> ? htab_t htab = (htab_t) data;
>
> - ?if (dv_is_value_p (var->dv))
> + ?if (dv_is_value_p (var->dv)
> + ? ? ?|| TREE_CODE (dv_as_decl (var->dv)) == DEBUG_EXPR_DECL)
> ? ? {
> ? ? ? value_chain vc
> ? ? ? ?= (value_chain) htab_find_with_hash (value_chains, var->dv,
> @@ -6703,7 +6738,8 @@ static void
> ?check_changed_vars_2 (variable var, htab_t htab)
> ?{
> ? variable_was_changed (var, NULL);
> - ?if (dv_is_value_p (var->dv))
> + ?if (dv_is_value_p (var->dv)
> + ? ? ?|| TREE_CODE (dv_as_decl (var->dv)) == DEBUG_EXPR_DECL)
> ? ? {
> ? ? ? value_chain vc
> ? ? ? ?= (value_chain) htab_find_with_hash (value_chains, var->dv,
>
> ? ? ? ?Jakub
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]