From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17784 invoked by alias); 22 Apr 2012 18:09:10 -0000 Received: (qmail 17775 invoked by uid 22791); 22 Apr 2012 18:09:08 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,TW_EP,T_RP_MATCHES_RCVD,T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 22 Apr 2012 18:08:48 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3MI8l8E015538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 22 Apr 2012 14:08:47 -0400 Received: from freie.oliva.athome.lsd.ic.unicamp.br (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q3MI8iFL013861 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 22 Apr 2012 14:08:46 -0400 Received: from livre.localdomain (livre-to-gw.oliva.athome.lsd.ic.unicamp.br [172.31.160.19]) by freie.oliva.athome.lsd.ic.unicamp.br (8.14.5/8.14.5) with ESMTP id q3MI8fvJ024160 for ; Sun, 22 Apr 2012 15:08:42 -0300 Received: from livre.localdomain (aoliva@localhost.localdomain [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id q3MI8fMb027915; Sun, 22 Apr 2012 15:08:41 -0300 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id q3MI8dHO027913; Sun, 22 Apr 2012 15:08:39 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: Re: [PR debug/47624] improve value tracking in non-VTA locations References: Date: Sun, 22 Apr 2012 18:09:00 -0000 In-Reply-To: (Alexandre Oliva's message of "Sat, 04 Jun 2011 07:43:24 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-04/txt/msg01320.txt.bz2 --=-=-= Content-length: 2500 On Jun 4, 2011, Alexandre Oliva wrote: > On Feb 15, 2011, Alexandre Oliva wrote: >> VTA only tracks locations of gimple regs, while addressable variables >> still use the old var tracking strategy. This means addressable >> variables, during var-tracking, got locations that were not based on >> VALUEs, which failed immediately in the presence of auto-inc addresses. >> The locations also tended to degrade in other ways, when a register >> holding an address happened to be overwritten at a later point. >> This patch arranges for us to track addresses of these variables as >> VALUEs, and to emit new locations for them when a location whose value >> was used to compute its address changes, fixing the problem. >> The patch was regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok to >> install? > Ping? Retested on both platforms, unchanged except for fixing the typo > s/deug/debug/ in the ChangeLog entry, that Jakub caught. > http://gcc.gnu.org/ml/gcc-patches/2011-02/msg00981.html Ping? Here's an updated patch that uses some of the recently-added infrastructure to notify dependent variables and values when their dependencies change. It didn't look reasonable to add a field to all variables parts, or even to all variables, just to hold a chain of loc_deps. For one-part variables, we reused cur_loc, but after some measurements I concluded it was perfectly ok to leave some backlinks behind or dangling, checking them on activation. It's not even a significant waste of memory: compare-debug bootstraps on x86_64- and i686-linux-gnu leave only 1 loc_exp_dep allocated in the pool I created for NOT_ONEPART loc_exp_deps in 3447 of the 5172 functions that leave any loc_exp_deps dangling off dependent values, at the end of var-tracking. Of all these 5172 functions, only 4 ever went beyond the initial pool allocation of 64 loc_exp_deps, which is less than 0.05%, with 98 as the highest count on the bootstraps. A 32 initial allocation would have been enough to cover 99.71% of the functions that have backlinks left behind at the end of var-tracking (thus released along with the pool), but since even 64 loc_exp_deps add up to as little as 512 pointers (half a 4KB page), I decided to leave it at that. Regstrapped on x86_64- and i686-linux-gnu. This ought to fix gcc.dg/guality/pr43077-1.c -O1 on powerpc (which is what the bug report is about), but I only verified that by examining a cross compiler output. Ok to install? --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=vta-vartrack-use-dstv-srcv-pr47624.patch Content-Transfer-Encoding: quoted-printable Content-length: 11211 for gcc/ChangeLog from Alexandre Oliva PR debug/47624 * var-tracking.c (loc_exp_dep_pool): New. (vt_emit_notes): Create and release the pool. (compute_bb_dataflow): Use value-based locations in MO_VAL_SET. (emit_notes_in_bb): Likewise. (loc_exp_dep_insert): Deal with NOT_ONEPART vars. (notify_dependents_of_changed_value): Likewise. (notify_dependents_of_resolved_value): Check that NOT_ONEPART variables don't have a VAR_LOC_DEP_LST. (emit_note_insn_var_location): Expand NOT_ONEPART locs that are VALUEs or MEMs of VALUEs. Index: gcc/var-tracking.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/var-tracking.c.orig 2012-04-13 12:54:10.000000000 -0300 +++ gcc/var-tracking.c 2012-04-18 03:47:48.000000000 -0300 @@ -474,6 +474,9 @@ static alloc_pool loc_chain_pool; /* Alloc pool for struct shared_hash_def. */ static alloc_pool shared_hash_pool; =20 +/* Alloc pool for struct loc_exp_dep_s for NOT_ONEPART variables. */ +static alloc_pool loc_exp_dep_pool; + /* Changed variables, notes will be emitted for them. */ static htab_t changed_variables; =20 @@ -6284,29 +6287,41 @@ compute_bb_dataflow (basic_block bb) { rtx loc =3D mo->u.loc; rtx val, vloc, uloc; + rtx dstv, srcv; =20 vloc =3D loc; uloc =3D XEXP (vloc, 1); val =3D XEXP (vloc, 0); vloc =3D uloc; =20 + if (GET_CODE (uloc) =3D=3D SET) + { + dstv =3D SET_DEST (uloc); + srcv =3D SET_SRC (uloc); + } + else + { + dstv =3D uloc; + srcv =3D NULL; + } + if (GET_CODE (val) =3D=3D CONCAT) { - vloc =3D XEXP (val, 1); + dstv =3D vloc =3D XEXP (val, 1); val =3D XEXP (val, 0); } =20 if (GET_CODE (vloc) =3D=3D SET) { - rtx vsrc =3D SET_SRC (vloc); + srcv =3D SET_SRC (vloc); =20 - gcc_assert (val !=3D vsrc); + gcc_assert (val !=3D srcv); gcc_assert (vloc =3D=3D uloc || VAL_NEEDS_RESOLUTION (loc)); =20 - vloc =3D SET_DEST (vloc); + dstv =3D vloc =3D SET_DEST (vloc); =20 if (VAL_NEEDS_RESOLUTION (loc)) - val_resolve (out, val, vsrc, insn); + val_resolve (out, val, srcv, insn); } else if (VAL_NEEDS_RESOLUTION (loc)) { @@ -6322,45 +6337,53 @@ compute_bb_dataflow (basic_block bb) if (REG_P (uloc)) var_reg_delete (out, uloc, true); else if (MEM_P (uloc)) - var_mem_delete (out, uloc, true); + { + gcc_assert (MEM_P (dstv)); + gcc_assert (MEM_ATTRS (dstv) =3D=3D MEM_ATTRS (uloc)); + var_mem_delete (out, dstv, true); + } } else { bool copied_p =3D VAL_EXPR_IS_COPIED (loc); - rtx set_src =3D NULL; + rtx src =3D NULL, dst =3D uloc; enum var_init_status status =3D VAR_INIT_STATUS_INITIALIZED; =20 if (GET_CODE (uloc) =3D=3D SET) { - set_src =3D SET_SRC (uloc); - uloc =3D SET_DEST (uloc); + src =3D SET_SRC (uloc); + dst =3D SET_DEST (uloc); } =20 if (copied_p) { if (flag_var_tracking_uninit) { - status =3D find_src_status (in, set_src); + status =3D find_src_status (in, src); =20 if (status =3D=3D VAR_INIT_STATUS_UNKNOWN) - status =3D find_src_status (out, set_src); + status =3D find_src_status (out, src); } =20 - set_src =3D find_src_set_src (in, set_src); + src =3D find_src_set_src (in, src); } =20 - if (REG_P (uloc)) - var_reg_delete_and_set (out, uloc, !copied_p, - status, set_src); - else if (MEM_P (uloc)) - var_mem_delete_and_set (out, uloc, !copied_p, - status, set_src); + if (REG_P (dst)) + var_reg_delete_and_set (out, dst, !copied_p, + status, srcv); + else if (MEM_P (dst)) + { + gcc_assert (MEM_P (dstv)); + gcc_assert (MEM_ATTRS (dstv) =3D=3D MEM_ATTRS (dst)); + var_mem_delete_and_set (out, dstv, !copied_p, + status, srcv); + } } } else if (REG_P (uloc)) var_regno_delete (out, REGNO (uloc)); =20 - val_store (out, val, vloc, insn, true); + val_store (out, val, dstv, insn, true); } break; =20 @@ -7602,8 +7625,13 @@ loc_exp_insert_dep (variable var, rtx x, if (VAR_LOC_DEP_LST (xvar) && VAR_LOC_DEP_LST (xvar)->dv =3D=3D var->dv) return; =20 - VEC_quick_push (loc_exp_dep, VAR_LOC_DEP_VEC (var), NULL); - led =3D VEC_last (loc_exp_dep, VAR_LOC_DEP_VEC (var)); + if (var->onepart =3D=3D NOT_ONEPART) + led =3D (loc_exp_dep *) pool_alloc (loc_exp_dep_pool); + else + { + VEC_quick_push (loc_exp_dep, VAR_LOC_DEP_VEC (var), NULL); + led =3D VEC_last (loc_exp_dep, VAR_LOC_DEP_VEC (var)); + } led->dv =3D var->dv; led->value =3D x; =20 @@ -7679,8 +7707,12 @@ notify_dependents_of_resolved_value (var =20 gcc_checking_assert (dv_changed_p (dv)); } - else if (!dv_changed_p (dv)) - continue; + else + { + gcc_checking_assert (dv_onepart_p (dv) !=3D NOT_ONEPART); + if (!dv_changed_p (dv)) + continue; + } =20 var =3D (variable) htab_find_with_hash (vars, dv, dv_htab_hash (dv)); =20 @@ -8135,11 +8167,23 @@ emit_note_insn_var_location (void **varp else if (last_limit > VAR_PART_OFFSET (var, i)) continue; offset =3D VAR_PART_OFFSET (var, i); - if (!var->var_part[i].cur_loc) + loc2 =3D var->var_part[i].cur_loc; + if (loc2 && GET_CODE (loc2) =3D=3D MEM + && GET_CODE (XEXP (loc2, 0)) =3D=3D VALUE) + { + rtx depval =3D XEXP (loc2, 0); + + loc2 =3D vt_expand_loc (loc2, vars); + + if (loc2) + loc_exp_insert_dep (var, depval, vars); + } + if (!loc2) { complete =3D false; continue; } + gcc_checking_assert (GET_CODE (loc2) !=3D VALUE); for (lc =3D var->var_part[i].loc_chain; lc; lc =3D lc->next) if (var->var_part[i].cur_loc =3D=3D lc->loc) { @@ -8147,7 +8191,6 @@ emit_note_insn_var_location (void **varp break; } gcc_assert (lc); - loc2 =3D var->var_part[i].cur_loc; } =20 offsets[n_var_parts] =3D offset; @@ -8361,7 +8404,6 @@ notify_dependents_of_changed_value (rtx=20 while ((led =3D VAR_LOC_DEP_LST (var))) { decl_or_value ldv =3D led->dv; - void **islot; variable ivar; =20 /* Deactivate and remove the backlink, as it was =E2=80=9Cused up=E2= =80=9D. It @@ -8386,13 +8428,34 @@ notify_dependents_of_changed_value (rtx=20 VEC_safe_push (rtx, stack, *changed_values_stack, dv_as_rtx (ldv)); break; =20 - default: - islot =3D htab_find_slot_with_hash (htab, ldv, dv_htab_hash (ldv), - NO_INSERT); - ivar =3D (variable) *islot; + case ONEPART_VDECL: + ivar =3D (variable) htab_find_with_hash (htab, ldv, dv_htab_hash (ldv)); gcc_checking_assert (!VAR_LOC_DEP_LST (ivar)); variable_was_changed (ivar, NULL); break; + + case NOT_ONEPART: + pool_free (loc_exp_dep_pool, led); + ivar =3D (variable) htab_find_with_hash (htab, ldv, dv_htab_hash (ldv)); + if (ivar) + { + int i =3D ivar->n_var_parts; + while (i--) + { + rtx loc =3D ivar->var_part[i].cur_loc; + + if (loc && GET_CODE (loc) =3D=3D MEM + && XEXP (loc, 0) =3D=3D val) + { + variable_was_changed (ivar, NULL); + break; + } + } + } + break; + + default: + gcc_unreachable (); } } } @@ -8729,29 +8792,41 @@ emit_notes_in_bb (basic_block bb, datafl { rtx loc =3D mo->u.loc; rtx val, vloc, uloc; + rtx dstv, srcv; =20 vloc =3D loc; uloc =3D XEXP (vloc, 1); val =3D XEXP (vloc, 0); vloc =3D uloc; =20 + if (GET_CODE (uloc) =3D=3D SET) + { + dstv =3D SET_DEST (uloc); + srcv =3D SET_SRC (uloc); + } + else + { + dstv =3D uloc; + srcv =3D NULL; + } + if (GET_CODE (val) =3D=3D CONCAT) { - vloc =3D XEXP (val, 1); + dstv =3D vloc =3D XEXP (val, 1); val =3D XEXP (val, 0); } =20 if (GET_CODE (vloc) =3D=3D SET) { - rtx vsrc =3D SET_SRC (vloc); + srcv =3D SET_SRC (vloc); =20 - gcc_assert (val !=3D vsrc); + gcc_assert (val !=3D srcv); gcc_assert (vloc =3D=3D uloc || VAL_NEEDS_RESOLUTION (loc)); =20 - vloc =3D SET_DEST (vloc); + dstv =3D vloc =3D SET_DEST (vloc); =20 if (VAL_NEEDS_RESOLUTION (loc)) - val_resolve (set, val, vsrc, insn); + val_resolve (set, val, srcv, insn); } else if (VAL_NEEDS_RESOLUTION (loc)) { @@ -8767,39 +8842,47 @@ emit_notes_in_bb (basic_block bb, datafl if (REG_P (uloc)) var_reg_delete (set, uloc, true); else if (MEM_P (uloc)) - var_mem_delete (set, uloc, true); + { + gcc_assert (MEM_P (dstv)); + gcc_assert (MEM_ATTRS (dstv) =3D=3D MEM_ATTRS (uloc)); + var_mem_delete (set, dstv, true); + } } else { bool copied_p =3D VAL_EXPR_IS_COPIED (loc); - rtx set_src =3D NULL; + rtx src =3D NULL, dst =3D uloc; enum var_init_status status =3D VAR_INIT_STATUS_INITIALIZED; =20 if (GET_CODE (uloc) =3D=3D SET) { - set_src =3D SET_SRC (uloc); - uloc =3D SET_DEST (uloc); + src =3D SET_SRC (uloc); + dst =3D SET_DEST (uloc); } =20 if (copied_p) { - status =3D find_src_status (set, set_src); + status =3D find_src_status (set, src); =20 - set_src =3D find_src_set_src (set, set_src); + src =3D find_src_set_src (set, src); } =20 - if (REG_P (uloc)) - var_reg_delete_and_set (set, uloc, !copied_p, - status, set_src); - else if (MEM_P (uloc)) - var_mem_delete_and_set (set, uloc, !copied_p, - status, set_src); + if (REG_P (dst)) + var_reg_delete_and_set (set, dst, !copied_p, + status, srcv); + else if (MEM_P (dst)) + { + gcc_assert (MEM_P (dstv)); + gcc_assert (MEM_ATTRS (dstv) =3D=3D MEM_ATTRS (dst)); + var_mem_delete_and_set (set, dstv, !copied_p, + status, srcv); + } } } else if (REG_P (uloc)) var_regno_delete (set, REGNO (uloc)); =20 - val_store (set, val, vloc, insn, true); + val_store (set, val, dstv, insn, true); =20 emit_notes_for_changes (next_insn, EMIT_NOTE_BEFORE_INSN, set->vars); @@ -8908,9 +8991,13 @@ vt_emit_notes (void) emit_notes =3D true; =20 if (MAY_HAVE_DEBUG_INSNS) - dropped_values =3D htab_create (cselib_get_next_uid () * 2, - variable_htab_hash, variable_htab_eq, - variable_htab_free); + { + dropped_values =3D htab_create (cselib_get_next_uid () * 2, + variable_htab_hash, variable_htab_eq, + variable_htab_free); + loc_exp_dep_pool =3D create_alloc_pool ("loc_exp_dep pool", + sizeof (loc_exp_dep), 64); + } =20 dataflow_set_init (&cur); =20 @@ -8935,7 +9022,11 @@ vt_emit_notes (void) dataflow_set_destroy (&cur); =20 if (MAY_HAVE_DEBUG_INSNS) - htab_delete (dropped_values); + { + free_alloc_pool (loc_exp_dep_pool); + loc_exp_dep_pool =3D NULL; + htab_delete (dropped_values); + } =20 emit_notes =3D false; } --=-=-= Content-length: 258 -- Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist Red Hat Brazil Compiler Engineer --=-=-=--